{"id":154466,"date":"2020-09-11T23:47:02","date_gmt":"2020-09-11T15:47:02","guid":{"rendered":"http:\/\/4563.org\/?p=154466"},"modified":"2020-09-11T23:47:02","modified_gmt":"2020-09-11T15:47:02","slug":"jenkins-%e4%b8%ad-docker-%e5%88%86%e5%b1%82%e6%9e%84%e5%bb%ba%e7%bc%93%e5%ad%98%e6%97%a0%e6%95%88%e9%97%ae%e9%a2%98%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=154466","title":{"rendered":"Jenkins \u4e2d Docker \u5206\u5c42\u6784\u5efa\u7f13\u5b58\u65e0\u6548\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Jenkins \u4e2d Docker \u5206\u5c42\u6784\u5efa\u7f13\u5b58\u65e0\u6548\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lawsiki <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h3>\u80cc\u666f\uff1a<\/h3>\n<ul>\n<li>\u672c\u673a macOS\uff0cdocker \u7248\u672c\uff1aDocker version 19.03.8, build afacb8b<\/li>\n<li>jenkins \u6784\u5efa\u670d\u52a1\u5668 CentOS\uff0cdocker \u7248\u672c\uff1aDocker version 19.03.12, build 48a66213fe<\/li>\n<\/ul>\n<p>Jenkins \u6784\u5efa\u7684\u6d41\u7a0b\u662f<\/p>\n<ul>\n<li>\u6784\u5efa\u6d41\u7a0b\u4f7f\u7528 Jenkins \u7684 pipline<\/li>\n<li>\u4f7f\u7528 jenkins \u81ea\u5e26\u7684 git \u547d\u4ee4\u62c9\u53d6\u6307\u5b9a\u5206\u652f<\/li>\n<li>maven \u6253\u5305 jar<\/li>\n<li>\u6784\u5efa docker \u955c\u50cf<\/li>\n<li>\u63a8\u9001 docker \u955c\u50cf\u8fd0\u884c<\/li>\n<\/ul>\n<p>\u521a\u5f00\u59cb\u4f7f\u7528\u7684\u662f springboot \u7684 fatjar\uff0c\u95ee\u9898\u5c31\u662f\u6bcf\u6b21\u6784\u5efa\u63a8\u9001\u7684\u65f6\u5019\u90fd\u8981\u91cd\u65b0\u6253\u5305 100 \u591a M\uff0c\u5f88\u8d39\u65f6<\/p>\n<p>\u73b0\u5728\u60f3\u4f7f\u7528 docker \u5206\u5c42\u955c\u50cf\u7f13\u5b58\u7684\u539f\u7406\uff0c\u5c06 maven \u6784\u5efa\u62c6\u5206\u4e3a lib \u548c app.jar \uff0c\u8fd9\u6837\u6bcf\u6b21\u6784\u5efa\u53ea\u9700\u8981\u51e0\u767e k \u5c31\u591f\u4e86\uff0c\u672c\u5730\u6d4b\u8bd5\u90fd\u6b63\u5e38\uff0c\u6ca1\u6709\u66f4\u6539\u4f9d\u8d56\u7684\u65f6\u5019\uff0c\u7b2c\u4e8c\u6b21\u6784\u5efa\u90fd\u662f\u77ac\u95f4\u5b8c\u6210<\/p>\n<p>\u4f46\u662f\u653e\u5230 Jenkins \u4e0a\u8dd1\u7684\u65f6\u5019\uff0c\u53d1\u73b0 14\uff0c15 \u884c\u4e24\u4e2a\u547d\u4ee4\u5e76\u6ca1\u6709\u8d70\u7f13\u5b58\uff0c\u8bf7\u95ee\u6709\u4eba\u78b0\u5230\u8fc7\u5417\uff1f<\/p>\n<p>Dockerfile <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200913_5f5e8378bb9cf.jpg\" alt=\"Jenkins \u4e2d Docker \u5206\u5c42\u6784\u5efa\u7f13\u5b58\u65e0\u6548\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\" \/><\/p>\n<p>Jenkins \u7684 git \u66f4\u65b0\u65e5\u5fd7 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200913_5f5e837ce3616.jpg\" alt=\"Jenkins \u4e2d Docker \u5206\u5c42\u6784\u5efa\u7f13\u5b58\u65e0\u6548\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\" \/><\/p>\n<p>Jenkins \u6784\u5efa\u65e5\u5fd7 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200913_5f5e8380b7ad8.jpg\" alt=\"Jenkins \u4e2d Docker \u5206\u5c42\u6784\u5efa\u7f13\u5b58\u65e0\u6548\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\" \/><\/p>\n<p>\u672c\u5730\u6784\u5efa\u65e5\u5fd7 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200913_5f5e8384e4a0b.jpg\" alt=\"Jenkins \u4e2d Docker \u5206\u5c42\u6784\u5efa\u7f13\u5b58\u65e0\u6548\u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\" \/><\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3256506\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Aliencn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u50cf\u662f\u6709\u4e9b\u64cd\u4f5c\u4fee\u6539\u4e86\u539f\u6587\u4ef6\u7684\u65f6\u95f4\u6233\uff0c\u8ba9 docker \u8ba4\u4e3a\u8fd9\u662f\u65b0\u6587\u4ef6\u5c31\u653e\u5f03\u4f7f\u7528\u7f13\u5b58\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3256507\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : lawsiki <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Aliencn #1 \u67e5\u8fc7\u597d\u50cf\u662f git checkout \u7684\u65f6\u5019\u4fee\u6539\u6587\u4ef6\u65f6\u95f4\u4e86\uff0c\u4f46\u662f\u6211\u5c1d\u8bd5 \u4f7f\u7528 find .\/ | grep -v .git | xargs touch -t 200001010000.00 \u4fee\u6539\u6587\u4ef6\u65f6\u95f4\u540e\u8fd8\u662f\u4e00\u6837\u7684\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3256508\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : calmzhu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u4e0b jenkinsFile \u6587\u4ef6<\/p>\n<p>\u7136\u540e\u5728 dockerbuild \u4e4b\u524d\u5c06 target\/lib \u8003\u5230\u7b2c\u4e09\u65b9\u76ee\u5f55\u3002\u7528 hash \u6bd4\u5bf9\u4e00\u4e0b\u4e24\u6b21\u4e4b\u95f4\u7684\u6587\u4ef6\u770b\u770b<\/p>\n<p>\u7136\u540e\u7528 Jenkins \u65f6 \u5efa\u8bae\u4e0d\u8981\u7ba1\u672c\u5730\u8fc7\u4e0d\u8fc7\u3002Jenkins \u8ddf\u672c\u5730\u73af\u5883\u53ef\u4ee5\u5dee\u975e\u5e38\u591a\u3002\u9664\u975e\u5bf9\u67d0\u4e2a\u6b65\u9aa4\u4f9d\u8d56\u7684\u73af\u5883\u6781\u4e3a\u6e05\u695a\u3002\u770b\u672c\u5730\u53cd\u800c\u9650\u5236\u81ea\u5df1\u6392\u67e5\u95ee\u9898                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3256509\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : lawsiki <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @calmzhu #3 \u6069\uff0c\u4e4b\u524d\u9677\u5165\u8bef\u533a\u4e86\uff0c\u4e00\u76f4\u4ee5\u4e3a\u662f git \u7684\u95ee\u9898\uff0c\u6392\u9664\u6cd5\u5c1d\u8bd5\u540e\u53d1\u73b0\u662f\u5728\u6a21\u5757\u4f9d\u8d56\u4e86\u53e6\u4e00\u4e2a common \u6a21\u5757\uff0c\u800c common \u6a21\u5757\u6bcf\u6b21\u90fd\u4f1a install\uff0c\u6240\u4ee5 lib \u5c31\u65e0\u6cd5\u7f13\u5b58\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Jenkins \u4e2d Docker &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/154466"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154466"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/154466\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154466"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}