{"id":1934,"date":"2020-05-14T15:58:03","date_gmt":"2020-05-14T12:58:03","guid":{"rendered":"https:\/\/artem.services\/?p=1934"},"modified":"2020-05-14T15:58:03","modified_gmt":"2020-05-14T12:58:03","slug":"jenkins-active-choice-harbor-images-tag","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1934","title":{"rendered":"Jenkins &#8212; Active Choice: Harbor &#8212; Images tag"},"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>\u0414\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0442\u0435\u0433\u0430 \u043e\u0431\u0440\u0430\u0437\u0430, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/plugins.jenkins.io\/uno-choice\/\" target=\"_blank\" rel=\"noopener noreferrer\">Active Choices<\/a><\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <strong>Jenkins<\/strong>&#39;\u0430<\/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>\u0420\u0430\u0437\u0434\u0435\u043b &quot;<strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438<\/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>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0432\u043a\u043b\u0430\u0434\u043a\u0435 &quot;<strong>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435<\/strong>&quot; \u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c &quot;<strong>Active Choices<\/strong>&quot;<\/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>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e. \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/plugins.jenkins.io\/aws-java-sdk\/\" target=\"_blank\" rel=\"noopener noreferrer\">Amazon Web Services SDK<\/a><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c &quot;<strong>New Item<\/strong>&quot; &#8212; &quot;<strong>Pipeline<\/strong>&quot;, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0430, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &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>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e &quot;<strong>Groovy Script<\/strong>&quot; \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0443\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nimport jenkins.model.*\r\nimport groovy.json.JsonSlurper\r\n\r\ncredentialsId = 'harbor_credentials'\r\nharborRepo = 'https:\/\/harbor.artem.services\/api\/repositories\/artem\/site'\r\n\r\ndef creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(\r\n  com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, Jenkins.instance, null, null ).find{\r\n    it.id == credentialsId}\r\n\r\ndef addr = &quot;${harborRepo}\/tags&quot;\r\ndef authString = &quot;${creds.username}:${creds.password}&quot;.getBytes().encodeBase64().toString()\r\ndef conn = addr.toURL().openConnection()\r\nconn.setRequestProperty( &quot;Authorization&quot;, &quot;Basic ${authString}&quot; )\r\ndef response_json = &quot;${conn.content.text}&quot;\r\ndef slurper = new JsonSlurper()\r\ndef parsed = slurper.parseText(response_json)\r\n\r\ndef tags=[]\r\n\r\nfor (tag in parsed){\r\n    tags.add(tag.name);\r\n}\r\n\r\nreturn tags\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>\u0413\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, &quot;<strong>credentialsId<\/strong>&quot; &#8212; Jenkins Credentials ID \u0441 \u043b\u043e\u0433\u0438\u043d\u043e\u043c \u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u043c \u043a <strong>Harbor<\/strong>&#39;\u0443;<\/p>\n<p>&quot;<strong>harborRepo<\/strong>&quot; &#8212; \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0443\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 <strong>Pipeline<\/strong><\/p>\n<h3>Pipeline:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproperties([\r\n  parameters([\r\n    [$class: 'CascadeChoiceParameter', \r\n      choiceType: 'PT_SINGLE_SELECT', \r\n      description: 'Select Image',\r\n      filterLength: 1,\r\n      filterable: false,\r\n      name: 'ImageTag', \r\n      script: [\r\n        $class: 'GroovyScript', \r\n        script: [\r\n          classpath: [], \r\n          sandbox: false, \r\n          script: \r\n            '''\r\n            import jenkins.model.*\r\n            import groovy.json.JsonSlurper\r\n\r\n            credentialsId = 'harbor_credentials'\r\n            harborRepo = 'https:\/\/harbor.artem.services\/api\/repositories\/artem\/site'\r\n\r\n            def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(\r\n              com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, Jenkins.instance, null, null ).find{\r\n                it.id == credentialsId}\r\n\r\n            def addr = &quot;${harborRepo}\/tags&quot;\r\n            def authString = &quot;${creds.username}:${creds.password}&quot;.getBytes().encodeBase64().toString()\r\n            def conn = addr.toURL().openConnection()\r\n            conn.setRequestProperty( &quot;Authorization&quot;, &quot;Basic ${authString}&quot; )\r\n            def response_json = &quot;${conn.content.text}&quot;\r\n            def slurper = new JsonSlurper()\r\n            def parsed = slurper.parseText(response_json)\r\n\r\n            def tags=[]\r\n\r\n            for (tag in parsed){\r\n                tags.add(tag.name);\r\n            }\r\n\r\n            return tags\r\n            '''\r\n        ]\r\n      ]\r\n    ]\r\n  ])\r\n])\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u0414\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0442\u0435\u0433\u0430 \u043e\u0431\u0440\u0430\u0437\u0430, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u0433\u0438\u043d Active Choices \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Jenkins&#39;\u0430 &nbsp; \u0420\u0430\u0437\u0434\u0435\u043b &quot;\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438&quot; &nbsp; \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0432\u043a\u043b\u0430\u0434\u043a\u0435 &quot;\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435&quot; \u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c &quot;Active Choices&quot; \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e. \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043f\u043b\u0430\u0433\u0438\u043d Amazon Web Services SDK \u0421\u043e\u0437\u0434\u0430\u0435\u043c &quot;New Item&quot; &#8212; &quot;Pipeline&quot;, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0430, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &hellip; <a href=\"https:\/\/artem.services\/?p=1934\" 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: Harbor &#8212; Images tag&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":[37],"tags":[1455,1607,1549,125,581,1121],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1934"}],"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=1934"}],"version-history":[{"count":1,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1934\/revisions"}],"predecessor-version":[{"id":1935,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1934\/revisions\/1935"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}