{"id":3419,"date":"2021-09-18T17:09:45","date_gmt":"2021-09-18T08:09:45","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3419"},"modified":"2021-09-20T11:45:36","modified_gmt":"2021-09-20T02:45:36","slug":"jenkins-node-sample","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3419","title":{"rendered":"Jenkins pipeline sample"},"content":{"rendered":"<h1>Jenkins pipeline sample<\/h1>\n<p>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .<\/p>\n<h2>ECR \uc744 \uc774\uc6a9\ud55c \ubc30\ud3ec<\/h2>\n<p>\ucd94\uac00 \ud50c\ub7ec\uadf8\uc778 : Docker Pipeline, Amazon ECR, GitHub Integration<\/p>\n<pre><code class=\"language-groovy\">node {\n    stage(&quot;Get Source&quot;) {\n        git url: &quot;https:\/\/github.com\/skyer9\/HelloWorldWithActuator.git&quot;,\n            branch: &quot;master&quot;\n    }\n\n    stage(&quot;Build&quot;) {\n        sh &quot;chmod 700 gradlew&quot;\n        sh &quot;.\/gradlew clean&quot;\n        sh &quot;.\/gradlew bootJar&quot;\n    }\n\n    stage(&quot;Dockerize&quot;) {\n        sh &quot;docker build -t helloworld:0.1.${build_number} .&quot;\n        sh &quot;docker build -t helloworld:latest .&quot;\n    }\n\n    stage(&quot;Push to ECR&quot;) {\n        \/\/ ecr:&lt;Your region&gt;:&lt;Your Jenkins credential ID&gt;\n        \/\/ myrepo : \uc774\ubbf8\uc9c0\uba85\uacfc ECR \ub9ac\ud3ec\uc9c0\ud1a0\ub9ac \uc774\ub984\uc740 \uc77c\uce58\ud574\uc57c \ud55c\ub2e4.\n        docker.withRegistry(&#039;https:\/\/1234567890.dkr.ecr.ap-northeast-2.amazonaws.com&#039;, &#039;ecr:ap-northeast-2:ecr_user&#039;) {\n            docker.image(&#039;helloworld:latest&#039;).push()\n        }\n    }\n\n    stage(&quot;Run Nomad&quot;) {\n        \/\/ Nomad \uc6d0\uaca9 \uc11c\ubc84 \uc544\uc774\ud53c\n        \/\/ env.NOMAD_ADDR = &quot;http:\/\/nb.skyer9.pe.kr:4646&quot;\n\n        \/\/ \ud074\ub77c\uc774\uc5b8\ud2b8 \ub178\ub4dc \ud504\ub77c\uc774\ube57 \uc544\uc774\ud53c\n        def local_ipv4 = sh(script: &#039;wget -qO- http:\/\/instance-data\/latest\/meta-data\/local-ipv4&#039;, returnStdout: true)\n        env.NOMAD_ADDR = &quot;http:\/\/$local_ipv4:4646&quot;\n\n        sh &quot;sed -i &#039;s\/XXXXXXXXXX\/1234567890\/g&#039; private_ecr_hello_world.nomad&quot;\n        sh &quot;\/usr\/local\/bin\/nomad job run private_ecr_hello_world.nomad&quot;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Jenkins pipeline sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ECR \uc744 \uc774\uc6a9\ud55c \ubc30\ud3ec \ucd94\uac00 \ud50c\ub7ec\uadf8\uc778 : Docker Pipeline, Amazon ECR, GitHub Integration node { stage(&quot;Get Source&quot;) { git url: &quot;https:\/\/github.com\/skyer9\/HelloWorldWithActuator.git&quot;, branch:\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3419\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3419","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3419"}],"version-history":[{"count":7,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3419\/revisions"}],"predecessor-version":[{"id":3431,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3419\/revisions\/3431"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}