{"id":1809,"date":"2020-04-01T14:11:45","date_gmt":"2020-04-01T11:11:45","guid":{"rendered":"https:\/\/artem.services\/?p=1794"},"modified":"2020-04-02T19:17:47","modified_gmt":"2020-04-02T16:17:47","slug":"1809","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1809&lang=en","title":{"rendered":"Jenkins &#8212; Active Choice: Git branch"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-819\" 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>&nbsp;<\/p>\n<p>For a parameterized build with branch selection, you will need a plugin <a href=\"https:\/\/plugins.jenkins.io\/uno-choice\/\" target=\"_blank\" rel=\"noopener noreferrer\">Active Choices<\/a><\/p>\n<p>Go to <strong>Jenkins<\/strong> settings<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1782\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/001.png\" alt=\"\" width=\"349\" height=\"383\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/001.png 349w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/001-273x300.png 273w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Section &quot;<strong>Manage Plugins<\/strong>&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1783\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002.png\" alt=\"\" width=\"927\" height=\"493\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002.png 927w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002-300x160.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/002-768x408.png 768w\" sizes=\"(max-width: 927px) 100vw, 927px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Go to the &quot;<strong>Available<\/strong>&quot; tab and specify &quot;<strong>Active Choice<\/strong>&quot; in the search.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1796\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37.png\" alt=\"\" width=\"1412\" height=\"130\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37.png 1412w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37-300x28.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37-1024x94.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37-768x71.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37-954x88.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-10.55.37-1354x125.png 1354w\" sizes=\"(max-width: 1412px) 100vw, 1412px\" \/><\/p>\n<p>Install it.<\/p>\n<p>Create a &quot;<strong>New Item<\/strong>&quot; &#8212; &quot;<strong>Pipeline<\/strong>&quot;, indicate that it will be a parameterized project, and add the parameter &quot;<strong>Active Choices Reactive Parameter<\/strong>&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1803\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/004.png\" alt=\"\" width=\"445\" height=\"379\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/004.png 445w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/004-300x256.png 300w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>We indicate that this is &quot;<strong>Groovy Script<\/strong>&quot; and paste the following into it:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndef gettags = (&quot;git ls-remote -t -h ssh:\/\/git-codecommit.eu-west-1.amazonaws.com\/v1\/repos\/artem-services.git&quot;).execute()\r\nreturn gettags.text.readLines().collect { \r\n  it.split()[1].replaceAll('refs\/heads\/', '').replaceAll('refs\/tags\/', '').replaceAll(&quot;\\\\^\\\\{\\\\}&quot;, '')\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>Where &quot;<strong>ssh: \/\/git-codecommit.eu-west-1.amazonaws.com\/v1\/repos\/artem-services.git<\/strong>&quot; is the path to your repository. <strong>Jenkins<\/strong> must have access to this repository over <strong>SSH<\/strong><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1798\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11.png\" alt=\"\" width=\"1586\" height=\"1340\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11.png 1586w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11-300x253.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11-1024x865.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11-768x649.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11-1536x1298.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11-954x806.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.03.11-1354x1144.png 1354w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Now, when building with parameters, there will be a branch selection<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1800\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.04.36-1.png\" alt=\"\" width=\"453\" height=\"187\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.04.36-1.png 453w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.04.36-1-300x124.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1801\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.04.19.png\" alt=\"\" width=\"466\" height=\"185\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.04.19.png 466w, https:\/\/artem.services\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-01-at-11.04.19-300x119.png 300w\" sizes=\"(max-width: 466px) 100vw, 466px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; For a parameterized build with branch selection, you will need a plugin Active Choices Go to Jenkins settings &nbsp; Section &quot;Manage Plugins&quot; &nbsp; Go to the &quot;Available&quot; tab and specify &quot;Active Choice&quot; in the search. Install it. Create a &quot;New Item&quot; &#8212; &quot;Pipeline&quot;, indicate that it will be a parameterized project, and add the &hellip; <a href=\"https:\/\/artem.services\/?p=1809&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;Jenkins &#8212; Active Choice: Git branch&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[613],"tags":[1465,1467,433,617,1247],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1809"}],"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=1809"}],"version-history":[{"count":3,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1809\/revisions"}],"predecessor-version":[{"id":1813,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1809\/revisions\/1813"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}