{"id":873,"date":"2019-03-05T11:48:08","date_gmt":"2019-03-05T08:48:08","guid":{"rendered":"https:\/\/artem.services\/?p=826"},"modified":"2019-03-12T17:30:09","modified_gmt":"2019-03-12T14:30:09","slug":"jenkins-d0-bf-d1-80-d0-b8-d0-bc-d0-b5-d1-80-dsl-multibranch-pipeline","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=873&lang=en","title":{"rendered":"Jenkins &#8212; Example DSL Multibranch Pipeline"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-full wp-image-819 aligncenter\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo.png\" alt=\"\" width=\"1280\" height=\"412\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo.png 1280w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-300x97.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-768x247.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-1024x330.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2019\/02\/Jenkins-Logo-954x307.png 954w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p><span class=\"tlid-translation translation\"><span class=\"\" title=\"\">Example <strong>Multibranch Pipeline<\/strong> configuration file for a <strong>DSL<\/strong> module, with a custom <strong>Bitbucket<\/strong> server.<\/span> <span class=\"\" title=\"\">Which will include branches: &quot;<strong>develop<\/strong>&quot;, &quot;<strong>staging<\/strong>&quot; and &quot;<strong>master<\/strong>&quot;.<\/span> <span title=\"\">Will store the last <strong>15<\/strong> builds.<\/span> <span class=\"\" title=\"\">And look for <strong>Jenkins<\/strong> file along the path: &quot;<strong>.jenkins\/Jenkinsfile<\/strong>&quot;<\/span><br \/>\n<\/span><\/p>\n<ul>\n<li><span class=\"tlid-translation translation\"> <span title=\"\">Repository name: <strong>artem-dsl<\/strong><\/span><\/span><\/li>\n<li><span class=\"tlid-translation translation\"><span title=\"\">Owner (project name): <strong>dev<\/strong><\/span><\/span><\/li>\n<li><span class=\"tlid-translation translation\"><span class=\"\" title=\"\">Loans of Jenkins access to Bitbucket: <strong>svn-bibucket<\/strong><\/span><\/span><\/li>\n<\/ul>\n<pre class=\"brush: groovy; title: ; notranslate\" title=\"\">\r\nmultibranchPipelineJob('artem-dsl') {\r\n    displayName('Artem-DSL')\r\n    description('DSL test')\r\n    branchSources {\r\n        branchSource {\r\n            source {\r\n                bitbucket {\r\n                    serverUrl('https:\/\/git.artem.services')\r\n                    repoOwner('dev')\r\n                    repository('artem-dsl')\r\n                    credentialsId('svc-bitbucket')\r\n                    traits {\r\n                        headWildcardFilter {\r\n                            excludes('')\r\n                            includes('develop staging master')\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n    configure {\r\n      def traits = it \/ sources \/ data \/ 'jenkins.branch.BranchSource' \/ source \/ traits\r\n      traits &amp;amp;lt;&amp;amp;lt; 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {\r\n          strategyId(3) \/\/ detect all branches\r\n      }\r\n    }\r\n    factory {\r\n        workflowBranchProjectFactory {\r\n            scriptPath('.jenkins\/Jenkinsfile')\r\n        }\r\n    }\r\n    orphanedItemStrategy {\r\n        discardOldItems {\r\n            numToKeep(15)\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Example Multibranch Pipeline configuration file for a DSL module, with a custom Bitbucket server. Which will include branches: &quot;develop&quot;, &quot;staging&quot; and &quot;master&quot;. Will store the last 15 builds. And look for Jenkins file along the path: &quot;.jenkins\/Jenkinsfile&quot; Repository name: artem-dsl Owner (project name): dev Loans of Jenkins access to Bitbucket: svn-bibucket<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[613],"tags":[615,627,617,629],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/873"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=873"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/873\/revisions"}],"predecessor-version":[{"id":875,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/873\/revisions\/875"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}