{"id":19475,"date":"2025-04-19T01:48:34","date_gmt":"2025-04-18T17:48:34","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/19475.html"},"modified":"2025-04-19T01:48:34","modified_gmt":"2025-04-18T17:48:34","slug":"02_%e4%bd%bf%e7%94%a8docker%e5%9c%a8%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e9%83%a8%e7%bd%b2jekins%e5%ae%9e%e7%8e%b0%e9%a1%b9%e7%9b%ae%e7%9a%84%e8%87%aa%e5%8a%a8%e5%8c%96%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/19475.html","title":{"rendered":"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72"},"content":{"rendered":"<h2>02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72jenkins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72<\/h2>\n<h3>\u4e00\u3001\u4f7f\u7528docker\u62c9\u53d6\u963f\u91cc\u4e91\u5bb9\u5668\u79c1\u6709\u955c\u50cf\u4ed3\u5e93\u5185\u7684jenkins\u955c\u50cf<\/h3>\n<li>\u767b\u5f55\u963f\u91cc\u4e91Docker Registry<\/li>\n<p>$ sudo docker login <span class=\"token operator\">&#8212;<\/span>username&#061;wxxxo&#064;1xxx registry<span class=\"token punctuation\">.<\/span>cn<span class=\"token operator\">&#8211;<\/span>shanghai<span class=\"token punctuation\">.<\/span>aliyuncs<span class=\"token punctuation\">.<\/span>com<\/p>\n<p>\u7528\u4e8e\u767b\u5f55\u7684\u7528\u6237\u540d\u4e3a\u963f\u91cc\u4e91\u8d26\u53f7\u5168\u540d&#xff0c;\u5bc6\u7801\u4e3a\u5f00\u901a\u670d\u52a1\u65f6\u8bbe\u7f6e\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u5728\u8bbf\u95ee\u51ed\u8bc1\u9875\u9762\u4fee\u6539\u51ed\u8bc1\u5bc6\u7801\u3002<\/p>\n<li>\u4eceRegistry\u4e2d\u62c9\u53d6\u955c\u50cf<\/li>\n<p>$ sudo docker pull registry<span class=\"token punctuation\">.<\/span>cn<span class=\"token operator\">&#8211;<\/span>shanghai<span class=\"token punctuation\">.<\/span>aliyuncs<span class=\"token punctuation\">.<\/span>com<span class=\"token operator\">\/<\/span>xxx<span class=\"token operator\">\/<\/span>jenkins:<span class=\"token punctuation\">[<\/span>\u955c\u50cf\u7248\u672c\u53f7<span class=\"token punctuation\">]<\/span><\/p>\n<h3>\u4e8c\u3001\u521b\u5efajenkins\u5bb9\u5668\u5e76\u8fd0\u884c<\/h3>\n<p>$ sudo docker run <span class=\"token operator\">&#8211;<\/span>d <span class=\"token operator\">&#8211;<\/span>u root \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>p 8080:8080 \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>p 50000:50000 \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>v <span class=\"token operator\">\/<\/span>home<span class=\"token operator\">\/<\/span>docker<span class=\"token operator\">\/<\/span>jenkins_home:<span class=\"token operator\">\/<\/span><span class=\"token keyword\">var<\/span><span class=\"token operator\">\/<\/span>jenkins_home \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>v <span class=\"token operator\">\/<\/span><span class=\"token keyword\">var<\/span><span class=\"token operator\">\/<\/span>run<span class=\"token operator\">\/<\/span>docker<span class=\"token punctuation\">.<\/span>sock:<span class=\"token operator\">\/<\/span><span class=\"token keyword\">var<\/span><span class=\"token operator\">\/<\/span>run<span class=\"token operator\">\/<\/span>docker<span class=\"token punctuation\">.<\/span>sock \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>v <span class=\"token operator\">\/<\/span>usr<span class=\"token operator\">\/<\/span>bin<span class=\"token operator\">\/<\/span>docker:<span class=\"token operator\">\/<\/span>usr<span class=\"token operator\">\/<\/span>bin<span class=\"token operator\">\/<\/span>docker \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>v <span class=\"token operator\">\/<\/span>usr<span class=\"token operator\">\/<\/span>bin<span class=\"token operator\">\/<\/span>kubectl:<span class=\"token operator\">\/<\/span>usr<span class=\"token operator\">\/<\/span>bin<span class=\"token operator\">\/<\/span>kubectl \\\\<br \/>\n<span class=\"token operator\">&#8211;<\/span>v <span class=\"token operator\">\/<\/span>root<span class=\"token operator\">\/<\/span><span class=\"token punctuation\">.<\/span>kube<span class=\"token operator\">\/<\/span>config:<span class=\"token operator\">\/<\/span>root<span class=\"token operator\">\/<\/span><span class=\"token punctuation\">.<\/span>kube<span class=\"token operator\">\/<\/span>config \\\\<br \/>\n<span class=\"token operator\">&#8212;<\/span>name jenkins \\\\<br \/>\nregistry<span class=\"token punctuation\">.<\/span>cn<span class=\"token operator\">&#8211;<\/span>shanghai<span class=\"token punctuation\">.<\/span>aliyuncs<span class=\"token punctuation\">.<\/span>com<span class=\"token operator\">\/<\/span>xxx<span class=\"token operator\">\/<\/span>jenkins:xxx<\/p>\n<p>\u6bcf\u4e2a\u53c2\u6570\u7684\u542b\u4e49&#xff1a;<\/p>\n<ul>\n<li>\n<p>docker run: \u8fd0\u884c Docker \u5bb9\u5668\u7684\u547d\u4ee4\u3002<\/p>\n<\/li>\n<li>\n<p>-d: \u5728\u540e\u53f0\u8fd0\u884c\u5bb9\u5668&#xff0c;\u5373\u201cdetached\u201d\u6a21\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p>-u root: \u4ee5 root \u7528\u6237\u8eab\u4efd\u8fd0\u884c\u5bb9\u5668\u3002\u8fd9\u901a\u5e38\u7528\u4e8e\u786e\u4fdd\u5bb9\u5668\u5185\u7684\u8fdb\u7a0b\u5177\u6709\u8db3\u591f\u7684\u6743\u9650\u6267\u884c\u9700\u8981\u7684\u64cd\u4f5c\u3002<\/p>\n<\/li>\n<li>\n<p>-p 8080:8080: \u5c06\u5bb9\u5668\u5185\u90e8\u7684 8080 \u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u7684 8080 \u7aef\u53e3&#xff08;\u5bbf\u4e3b\u673a\u7aef\u53e3:\u5bb9\u5668\u5185\u90e8\u7aef\u53e3&#xff09;\u3002Jenkins \u670d\u52a1\u901a\u5e38\u5728 8080 \u7aef\u53e3\u4e0a\u8fd0\u884c\u3002<\/p>\n<\/li>\n<li>\n<p>-p 50000:50000: \u5c06\u5bb9\u5668\u5185\u90e8\u7684 50000 \u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u7684 50000 \u7aef\u53e3&#xff08;\u5bbf\u4e3b\u673a\u7aef\u53e3:\u5bb9\u5668\u5185\u90e8\u7aef\u53e3&#xff09;\u3002\u8fd9\u662f Jenkins \u4f7f\u7528\u7684\u7528\u4e8e\u6784\u5efa\u548c\u6267\u884c\u4efb\u52a1\u7684\u7aef\u53e3\u3002<\/p>\n<\/li>\n<li>\n<p>-v \/home\/docker\/jenkins_home:\/var\/jenkins_home: \u5c06\u5bbf\u4e3b\u673a\u4e0a\u7684\u76ee\u5f55&#xff08;\/home\/docker\/jenkins_home&#xff09;\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 \/var\/jenkins_home \u76ee\u5f55&#xff08;\u5bbf\u4e3b\u673a\u76ee\u5f55:\u5bb9\u5668\u5185\u90e8\u76ee\u5f55&#xff09;\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd Jenkins \u6570\u636e\u548c\u914d\u7f6e\u6301\u4e45\u5316&#xff0c;\u5373\u4f7f\u5bb9\u5668\u88ab\u5220\u9664&#xff0c;\u6570\u636e\u4ecd\u7136\u4fdd\u5b58\u5728\u5bbf\u4e3b\u673a\u4e0a\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\/home\/docker\/jenkins_home \u4e3a\u81ea\u5df1\u5728Linux\u7cfb\u7edf\u91cc\u521b\u5efa\u7684\u7528\u6765\u6301\u4e45\u5316jenkins\u6570\u636e\u7684\u76ee\u5f55&#xff0c;\u800c\/var\/jenkins_home\u662fdocker\u5bb9\u5668\u5185\u7684\u9ed8\u8ba4\u8def\u5f84&#xff0c;\u5373jenkins_home\u7684\u8def\u5f84\u5728docker\u5bb9\u5668\u5185\u7684\/var\u4e0b\u3002<\/p>\n<\/li>\n<li>\n<p>-v \/var\/run\/docker.sock:\/var\/run\/docker.sock<\/p>\n<p>\u5bbf\u4e3b\u673a\u4e0a\u7684\u76ee\u5f55&#xff08;\/var\/run\/docker.sock&#xff09;\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 \/var\/run\/docker.sock \u76ee\u5f55&#xff08;\u5bbf\u4e3b\u673a\u76ee\u5f55:\u5bb9\u5668\u5185\u90e8\u76ee\u5f55&#xff09;\u3002\u6302\u8f7d \u5bbf\u4e3b\u673a\u7684 Docker \u5957\u63a5\u5b57&#xff08;socket&#xff09;\u5230\u5bb9\u5668\u5185\u90e8&#xff0c;\u8ba9\u5bb9\u5668\u80fd\u591f\u63a7\u5236\u4f7f\u7528\u5bbf\u4e3b\u673a\u4e0a\u7684 Docker\u3002<\/p>\n<\/li>\n<li>\n<p>-v \/usr\/bin\/docker:\/usr\/bin\/docker<\/p>\n<p>\u5bbf\u4e3b\u673a\u4e0a\u7684\u76ee\u5f55&#xff08; \/usr\/bin\/docker&#xff09;\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 \/usr\/bin\/docker \u76ee\u5f55&#xff08;\u5bbf\u4e3b\u673a\u76ee\u5f55:\u5bb9\u5668\u5185\u90e8\u76ee\u5f55&#xff09;\u3002\u5c06\u5bbf\u4e3b\u673a\u4e0a\u7684 docker \u547d\u4ee4\u4e8c\u8fdb\u5236\u6587\u4ef6\u6302\u8f7d\u5230\u5bb9\u5668\u5185&#xff0c;\u4f7f\u5bb9\u5668\u5185\u90e8\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528 Docker \u547d\u4ee4\u3002<\/p>\n<\/li>\n<li>\n<p>-v \/usr\/bin\/kubectl:\/usr\/bin\/kubectl<\/p>\n<p>\u5bbf\u4e3b\u673a\u4e0a\u7684\u76ee\u5f55&#xff08;\/usr\/bin\/kubectl&#xff09;\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 \/usr\/bin\/kubectl \u76ee\u5f55&#xff08;\u5bbf\u4e3b\u673a\u76ee\u5f55:\u5bb9\u5668\u5185\u90e8\u76ee\u5f55&#xff09;\u3002\u5c06\u5bbf\u4e3b\u673a\u7684 kubectl \u547d\u4ee4\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u90e8&#xff0c;\u4f7f Jenkins \u5728\u5bb9\u5668\u4e2d\u53ef\u4ee5\u76f4\u63a5\u6267\u884c kubectl \u547d\u4ee4&#xff0c;\u7ba1\u7406 Kubernetes \u96c6\u7fa4\u3002<\/p>\n<\/li>\n<li>\n<p>-v \/root\/.kube\/config:\/root\/.kube\/config<\/p>\n<p>\u5bbf\u4e3b\u673a\u4e0a\u7684\u76ee\u5f55&#xff08;\/root\/.kube\/config&#xff09;\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 \/root\/.kube\/config \u76ee\u5f55&#xff08;\u5bbf\u4e3b\u673a\u76ee\u5f55:\u5bb9\u5668\u5185\u90e8\u76ee\u5f55&#xff09;\u3002\u5c06\u5bbf\u4e3b\u673a\u7684 Kubernetes \u914d\u7f6e\u6587\u4ef6\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u90e8&#xff0c;\u4f7f Jenkins \u80fd\u591f\u4ee5ROOT\u6743\u9650\u8bbf\u95ee Kubernetes \u96c6\u7fa4\u3002<\/p>\n<\/li>\n<li>\n<p>\u2013name jenkins: \u4e3a\u5bb9\u5668\u6307\u5b9a\u4e00\u4e2a\u540d\u79f0&#xff0c;\u5373 \u201cjenkins\u201d\u3002<\/p>\n<\/li>\n<li>\n<p>registry.cn-shanghai.aliyuncs.com\/xxx\/jenkins:2.491-jdk17: \u6307\u5b9a\u8981\u8fd0\u884c\u7684 Docker \u955c\u50cf\u7684\u540d\u79f0\u548c\u7248\u672c&#xff08;\u955c\u50cf\u540d\u79f0:\u7248\u672c\u53f7&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u767b\u5f55jenkins<\/h3>\n<p>\u901a\u8fc7\u8bbf\u95ee[\u670d\u52a1\u5668IP]:[jenkins\u7aef\u53e3]\u8bbf\u95eejenkins\u670d\u52a1&#xff0c;\u521a\u4f7f\u7528jenkins\u670d\u52a1\u65f6&#xff0c;\u9700\u8981\u4f7f\u7528jenkins\u63d0\u4f9b\u7684\u9ed8\u8ba4\u5bc6\u7801\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n<p>jenkins\u63d0\u4f9b\u7684\u9ed8\u8ba4\u5bc6\u7801\u8def\u5f84&#xff08;\u5728docker\u5bb9\u5668\u5185&#xff09;\u4e3a&#xff1a;<\/p>\n<p><span class=\"token operator\">\/<\/span><span class=\"token keyword\">var<\/span><span class=\"token operator\">\/<\/span>jenkins_home<span class=\"token operator\">\/<\/span>secrets<span class=\"token operator\">\/<\/span>initialAdminPassword<\/p>\n<p>&#xff08;\u5982\u679c\u5c06\u5bbf\u4e3b\u673a\u7684\u67d0\u4e2a\u76ee\u5f55\u8def\u5f84\u6302\u8f7d\u5230 \/var\/jenkins_home \u8def\u5f84&#xff09;&#xff1a;\u5982\u5c06\u5bbf\u4e3b\u673a\u4e0a\u7684\u76ee\u5f55&#xff08;\/home\/docker\/jenkins_home&#xff09;\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 \/var\/jenkins_home \u76ee\u5f55&#xff0c;\u90a3\u4e48\u9ed8\u8ba4\u5bc6\u7801\u8def\u5f84\u4e3a<\/p>\n<p><span class=\"token operator\">\/<\/span>home<span class=\"token operator\">\/<\/span>docker<span class=\"token operator\">\/<\/span>jenkins_home<span class=\"token operator\">\/<\/span>secrets<span class=\"token operator\">\/<\/span>initialAdminPassword<\/p>\n<p>\u5b89\u88c5\u63d2\u4ef6&#xff0c;\u5f53\u7136\u4e5f\u53ef\u4ee5\u8df3\u8fc7&#xff0c;\u4e0d\u8fc7\u4e00\u822c\u63a8\u8350\u6309\u7167jenkins\u7684\u63a8\u8350\u7684\u63d2\u4ef6\u3002\u5b89\u88c5\u5b8c\u6bd5\u540e&#xff0c;\u53ef\u4ee5\u521b\u5efajenkins\u7528\u6237\u3002<\/p>\n<h3>\u56db\u3001\u914d\u7f6e\u540d\u4e3adockerhub\u7684\u51ed\u8bc1<\/h3>\n<p>\u5728Jenkins\u4e2d\u914d\u7f6e\u540d\u4e3adockerhub\u7684\u51ed\u8bc1&#xff08;\u5b9e\u9645\u4e0a\u5c31\u662f\u81ea\u5df1\u7684\u8d26\u53f7\u5bc6\u7801&#xff09;&#xff0c;\u65b9\u4fbfJenkins\u5728\u6784\u5efadocker\u955c\u50cf\u8fc7\u7a0b\u4e2d&#xff0c;\u53ef\u4ee5\u767b\u5f55\u963f\u91cc\u4e91\u79c1\u6709\u4ed3\u5e93&#xff0c;\u5e76\u4e0a\u4f20\u5230\u963f\u91cc\u4e91\u79c1\u6709\u4ed3\u5e93\u5185\u3002<\/p>\n<li>\n<p>\u70b9\u51fb \u201cManage Jenkins\u201d&#xff08;\u7ba1\u7406 Jenkins&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fdb\u5165 \u201cManage Credentials\u201d&#xff08;\u7ba1\u7406\u51ed\u8bc1&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u70b9\u51fb \u201cAdd Credentials\u201d&#xff08;\u6dfb\u52a0\u51ed\u8bc1&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>Username&#xff08;\u7528\u6237\u540d&#xff09;&#xff1a; \u963f\u91cc\u4e91\u8d26\u53f7<\/p>\n<p>Password&#xff08;\u5bc6\u7801&#xff09;&#xff1a; \u963f\u91cc\u4e91\u5bc6\u7801<\/p>\n<p>ID&#xff08;\u552f\u4e00\u6807\u8bc6&#xff09;&#xff1a; dockerhub&#xff08;\u26a0\ufe0f \u8fd9\u4e2a ID \u4e4b\u540e\u8981\u5728 Jenkinsfile \u91cc\u7528&#xff0c;\u4e5f\u53ef\u4ee5\u8d77\u5176\u4ed6ID\u540d&#xff0c;\u4f46\u662f\u9700\u8981\u548cJenkinsfile\u91cc\u7684registryCredential\u4fdd\u6301\u4e00\u81f4&#xff09;\u3002<\/p>\n<\/li>\n<h3>\u4e94\u3001\u7f16\u5199dockerfile\u3001K8S\/deployment.yaml\u3001jenkinsfile\u6587\u4ef6<\/h3>\n<p>dockerfile\u6587\u4ef6&#xff1a;docker\u6253\u5305\u955c\u50cf\u65f6&#xff0c;\u53ef\u4ee5\u8bfb\u53d6\u8be5\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9&#xff0c;\u4f9d\u636e\u6587\u4ef6\u4e2d\u7684\u547d\u4ee4\u8fdb\u884c\u6253\u5305\u3002<\/p>\n<p>dockerfile\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\"># FROM \u6307\u5b9a\u4f7f\u7528\u54ea\u4e2a\u955c\u50cf\u4f5c\u4e3a\u57fa\u51c6<\/span><br \/>\n<span class=\"token keyword\">FROM<\/span> docker<span class=\"token punctuation\">.<\/span>m<span class=\"token punctuation\">.<\/span>daocloud<span class=\"token punctuation\">.<\/span>io<span class=\"token operator\">\/<\/span>openjdk:8u191<span class=\"token operator\">&#8211;<\/span>jdk<span class=\"token operator\">&#8211;<\/span>alpine<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u76ee\u5f55, \u5e76\u8bbe\u7f6e\u8be5\u76ee\u5f55\u4e3a\u5de5\u4f5c\u76ee\u5f55<\/span><br \/>\nRUN mkdir <span class=\"token operator\">&#8211;<\/span>p <span class=\"token operator\">\/<\/span>aaa<br \/>\nWORKDIR <span class=\"token operator\">\/<\/span>aaa<\/p>\n<p><span class=\"token comment\"># \u590d\u5236\u6587\u4ef6\u5230\u955c\u50cf\u4e2d<\/span><br \/>\n<span class=\"token comment\"># COPY target\/aaa-1.0.jar aaa.jar <\/span><br \/>\n<span class=\"token function\">COPY<\/span> aaa<span class=\"token operator\">&#8211;<\/span>1<span class=\"token punctuation\">.<\/span>0<span class=\"token punctuation\">.<\/span>jar <span class=\"token punctuation\">.<\/span><span class=\"token operator\">\/<\/span><\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e\u65f6\u533a<\/span><br \/>\nENV TZ&#061;Asia<span class=\"token operator\">\/<\/span>Shanghai<\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e JAVA_OPTS \u73af\u5883\u53d8\u91cf&#xff0c;\u53ef\u901a\u8fc7 docker run -e &#034;JAVA_OPTS&#061;&#034; \u8fdb\u884c\u8986\u76d6<\/span><br \/>\nENV JAVA_OPTS&#061;<span class=\"token string\">&#034;-Xms300m -Xmx300m -Djava.security.egd&#061;file:\/dev\/.\/urandom&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u5e94\u7528\u53c2\u6570&#xff0c;\u53ef\u901a\u8fc7 docker run -e &#034;ARGS&#061;&#034; \u6765\u8bbe\u7f6e&#xff0c;\u5982 -e &#034;ARGS&#061;&#8211;spring.profiles.active&#061;prod&#034;<\/span><br \/>\nENV ARGS&#061;<span class=\"token string\">&#034;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u66b4\u9732 8080 \u7aef\u53e3<\/span><br \/>\nEXPOSE 8080<\/p>\n<p><span class=\"token comment\"># \u542f\u52a8\u540e\u7aef\u670d\u52a1<\/span><br \/>\nCMD java $<span class=\"token punctuation\">{<\/span>JAVA_OPTS<span class=\"token punctuation\">}<\/span> <span class=\"token operator\">&#8211;<\/span>jar aaa<span class=\"token operator\">&#8211;<\/span>1<span class=\"token punctuation\">.<\/span>0<span class=\"token punctuation\">.<\/span>jar <span class=\"token variable\">$ARGS<\/span><\/p>\n<p>K8S\/deployment.yaml\u6587\u4ef6&#xff1a;K8S\u521b\u5efa\u5e94\u7528\u65f6&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u8be5\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u8fdb\u884c\u521b\u5efa\u3002<\/p>\n<p>K8S\/deployment.yaml\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token key atrule\">apiVersion<\/span><span class=\"token punctuation\">:<\/span> v1  <span class=\"token comment\"># apiVersion: v1&#xff1a;\u6307\u5b9a Kubernetes API \u7248\u672c&#xff0c;v1 \u9002\u7528\u4e8e Service \u8d44\u6e90<\/span><br \/>\n<span class=\"token key atrule\">kind<\/span><span class=\"token punctuation\">:<\/span> Service  <span class=\"token comment\"># \u5b9a\u4e49\u8be5\u8d44\u6e90\u7684\u7c7b\u578b\u662f\u4e00\u4e2a Service<\/span><br \/>\n<span class=\"token key atrule\">metadata<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> aaa <span class=\"token comment\"># \u5b9a\u4e49 Service \u7684\u540d\u79f0<\/span><br \/>\n<span class=\"token key atrule\">spec<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u5b9a\u4e49 Service \u7684\u8be6\u7ec6\u914d\u7f6e<\/span><br \/>\n  <span class=\"token key atrule\">type<\/span><span class=\"token punctuation\">:<\/span> NodePort  <span class=\"token comment\"># \u6307\u5b9a Service \u7c7b\u578b\u4e3a NodePort&#xff0c;\u5373\u5141\u8bb8\u5916\u90e8\u901a\u8fc7 NodeIP:nodePort \u8bbf\u95ee\u670d\u52a1\u3002<\/span><br \/>\n  <span class=\"token key atrule\">selector<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">app<\/span><span class=\"token punctuation\">:<\/span> aaa  <span class=\"token comment\"># \u8868\u793a\u8be5 Service \u53ea\u4f1a\u9009\u62e9 app: aaa \u8fd9\u4e2a\u6807\u7b7e\u7684 Pod \u4f5c\u4e3a\u540e\u7aef\u670d\u52a1\u3002<\/span><br \/>\n  <span class=\"token key atrule\">ports<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u5b9a\u4e49 Service \u7684\u7aef\u53e3\u6620\u5c04<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">protocol<\/span><span class=\"token punctuation\">:<\/span> TCP  <span class=\"token comment\"># \u6307\u5b9a\u4f7f\u7528 TCP \u4f5c\u4e3a\u901a\u4fe1\u534f\u8bae<\/span><br \/>\n      <span class=\"token key atrule\">port<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">8080<\/span>  <span class=\"token comment\"># \u8fd9\u662f Service \u5185\u90e8\u7684\u7aef\u53e3&#xff0c;\u5176\u4ed6 Pod \u8bbf\u95ee\u8be5 Service \u65f6\u4f7f\u7528\u8fd9\u4e2a\u7aef\u53e3\u3002 port \u4f1a\u8f6c\u53d1\u6d41\u91cf\u5230 targetPort&#xff0c;\u901a\u5e38\u5b83\u4eec\u53ef\u4ee5\u76f8\u540c&#xff0c;\u4f46\u4e0d\u5f3a\u5236\u76f8\u540c<\/span><br \/>\n      <span class=\"token key atrule\">nodePort<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">31678<\/span>  <span class=\"token comment\"># Kubernetes \u5728\u6bcf\u4e2a\u8282\u70b9\u4e0a\u5206\u914d\u7684\u7aef\u53e3\u53f7&#xff0c;\u7528\u4e8e\u5916\u90e8\u8bbf\u95ee<\/span><br \/>\n      <span class=\"token key atrule\">targetPort<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">8080<\/span>  <span class=\"token comment\"># \u8fd9\u662f Pod \u5185\u90e8\u8fd0\u884c\u7684\u5bb9\u5668\u76d1\u542c\u7684\u7aef\u53e3&#xff0c;\u5bf9\u5e94 Dockerfile \u91cc EXPOSE \u7684\u7aef\u53e3\u548c\u540e\u6587\u7684\u91cc\u7684 containerPort<\/span><br \/>\n      <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> http  <span class=\"token comment\"># \u7aef\u53e3\u540d\u79f0&#xff08;\u53ef\u4e0d\u5199&#xff09;<\/span><\/p>\n<p><span class=\"token punctuation\">&#8212;<\/span><br \/>\n<span class=\"token key atrule\">apiVersion<\/span><span class=\"token punctuation\">:<\/span> apps\/v1  <span class=\"token comment\"># \u6307\u5b9a Kubernetes API \u7248\u672c&#xff0c;apps\/v1 \u9002\u7528\u4e8e Deployment \u8d44\u6e90<\/span><br \/>\n<span class=\"token key atrule\">kind<\/span><span class=\"token punctuation\">:<\/span> Deployment  <span class=\"token comment\"># \u5b9a\u4e49\u8be5\u8d44\u6e90\u7684\u7c7b\u578b\u662f\u4e00\u4e2a Deployment&#xff0c;\u7528\u4e8e\u7ba1\u7406 Pod \u7684\u521b\u5efa\u548c\u66f4\u65b0<\/span><br \/>\n<span class=\"token key atrule\">metadata<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> aaa  <span class=\"token comment\"># Deployment \u7684\u540d\u79f0<\/span><br \/>\n  <span class=\"token key atrule\">annotations<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">kubernetes.io\/change-cause<\/span><span class=\"token punctuation\">:<\/span> registry<span class=\"token punctuation\">&#8211;<\/span>vpc.cn<span class=\"token punctuation\">&#8211;<\/span>shanghai.aliyuncs.com\/aaa\/aaa<span class=\"token punctuation\">:<\/span><span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">{<\/span>GIT_COMMIT<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">}<\/span>  <span class=\"token comment\"># \u7528\u4e8e\u8bb0\u5f55\u8be5 Deployment \u53d8\u66f4\u7684\u539f\u56e0&#xff0c;\u5e38\u7528\u4e8e\u56de\u6eda\u548c\u7248\u672c\u7ba1\u7406&#xff0c;\u5176\u4e2d {{GIT_COMMIT}} \u662f Git \u63d0\u4ea4\u7684\u7248\u672c\u53f7&#xff0c;\u901a\u5e38\u5728 CI\/CD \u8fc7\u7a0b\u4e2d\u4f1a\u88ab\u66ff\u6362\u4e3a\u5b9e\u9645\u503c&#xff0c;\u4f8b\u5982Jenkinsfile\u6587\u4ef6\u4e2d\u6709\u4e00\u6761\u547d\u4ee4\u4fbf\u662f\u67e5\u627e{{GIT_COMMIT}}\u5e76\u5c06\u5176\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u7248\u672c\u53f7<\/span><br \/>\n<span class=\"token key atrule\">spec<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u5b9a\u4e49 Deployment \u7684\u8be6\u7ec6\u914d\u7f6e<\/span><br \/>\n  <span class=\"token key atrule\">replicas<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">1<\/span>  <span class=\"token comment\"># \u6307\u5b9a\u526f\u672c\u6570&#xff0c;\u5373 Pod \u7684\u6570\u91cf\u4e3a 1<\/span><br \/>\n  <span class=\"token key atrule\">selector<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">matchLabels<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token key atrule\">app<\/span><span class=\"token punctuation\">:<\/span> aaa  <span class=\"token comment\"># \u8868\u793a\u8be5 Deployment \u53ea\u4f1a\u7ba1\u7406 app: aaa \u8fd9\u4e2a\u6807\u7b7e\u7684 Pod<\/span><br \/>\n  <span class=\"token key atrule\">template<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u5b9a\u4e49 Pod \u6a21\u677f&#xff0c;\u6240\u6709\u7531\u8be5 Deployment \u521b\u5efa\u7684 Pod \u90fd\u4f1a\u9075\u5faa\u6b64\u6a21\u677f<\/span><br \/>\n    <span class=\"token key atrule\">metadata<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token key atrule\">labels<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token key atrule\">app<\/span><span class=\"token punctuation\">:<\/span> aaa  <span class=\"token comment\"># \u7ed9 Pod \u6253\u4e0a app: aaa \u7684\u6807\u7b7e&#xff0c;\u4fbf\u4e8e Service \u53d1\u73b0\u8be5 Pod<\/span><br \/>\n    <span class=\"token key atrule\">spec<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u5b9a\u4e49 Pod \u7684\u8be6\u7ec6\u914d\u7f6e <\/span><br \/>\n      <span class=\"token key atrule\">containers<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> aaa  <span class=\"token comment\"># \u5bb9\u5668\u540d\u79f0<\/span><br \/>\n          <span class=\"token key atrule\">image<\/span><span class=\"token punctuation\">:<\/span> registry<span class=\"token punctuation\">&#8211;<\/span>vpc.cn<span class=\"token punctuation\">&#8211;<\/span>shanghai.aliyuncs.com\/aaa\/aaa<span class=\"token punctuation\">:<\/span><span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">{<\/span>GIT_COMMIT<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">}<\/span>  <span class=\"token comment\"># \u6307\u5b9a\u5bb9\u5668\u7684\u955c\u50cf\u5730\u5740&#xff0c;{{GIT_COMMIT}} \u4ee3\u8868 Git \u7248\u672c\u53f7&#xff0c;CI\/CD \u8fc7\u7a0b\u4e2d\u4f1a\u88ab\u66ff\u6362\u4e3a\u5b9e\u9645\u503c<\/span><br \/>\n          <span class=\"token key atrule\">ports<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">containerPort<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">8080<\/span>  <span class=\"token comment\"># \u5b9a\u4e49\u5bb9\u5668\u5185\u90e8\u76d1\u542c\u7684\u7aef\u53e3&#xff0c;\u5e94\u548cdockerfile\u91ccEXPOSE\u66b4\u9732\u7684\u7aef\u53e3\u4fdd\u6301\u4e00\u81f4<\/span><br \/>\n          <span class=\"token comment\"># \u4e0b\u9762\u662f\u5065\u5eb7\u68c0\u67e5\u914d\u7f6e<\/span><br \/>\n          <span class=\"token comment\"># livenessProbe:  # &#xff08;\u5b58\u6d3b\u63a2\u9488&#xff09;&#xff1a;\u68c0\u67e5\u5bb9\u5668\u662f\u5426\u5b58\u6d3b&#xff0c;\u82e5\u5931\u8d25 Kubernetes \u4f1a\u91cd\u542f\u8be5\u5bb9\u5668<\/span><br \/>\n          <span class=\"token comment\">#   httpGet:<\/span><br \/>\n          <span class=\"token comment\">#     path: \/user\/health_check  # \u901a\u8fc7 HTTP GET \u8bf7\u6c42<\/span><\/p>\n<p>Jenkinsfile\u6587\u4ef6&#xff1a;Jenkins\u5168\u6d41\u7a0b\u90e8\u7f72\u65f6&#xff0c;\u6839\u636e\u8be5\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9&#xff0c;\u8fdb\u884c\u5168\u6d41\u7a0b\u90e8\u7f72\u3002<\/p>\n<p>Jenkinsfile\u6587\u4ef6&#xff1a;<\/p>\n<p>pipeline <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5b9a\u4e49\u4e00\u4e2a\u5de5\u4f5c\u6d41<br \/>\n  environment <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>\u5b9a\u4e49\u73af\u5883\u53d8\u91cf<br \/>\n    <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>\u5b9a\u4e49Docker\u955c\u50cf\u4ed3\u5e93\u5730\u5740<br \/>\nregistry &#061; <span class=\"token string\">&#034;registry-vpc.cn-shanghai.aliyuncs.com\/aaa\/aaa&#034;<\/span><br \/>\n    registryCredential &#061; <span class=\"token string\">&#034;dockerhub&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>docker\u767b\u5f55\u963f\u91cc\u4e91\u7684\u51ed\u8bc1&#xff0c;\u5373\u914d\u7f6e\u7684\u8d26\u53f7\u5bc6\u7801&#xff0c;\u5b58\u50a8\u5728jekins\u7684Credential\u91cc<br \/>\n    parentWorkspace &#061; <span class=\"token string\">&#034;<span class=\"token variable\">$WORKSPACE<\/span>&#034;<\/span><br \/>\n    FAILED_STAGE&#061;<span class=\"token string\">&#034;&#034;<\/span><br \/>\n    CURRENT_ENVIRONMENT&#061;<span class=\"token string\">&#034;&#034;<\/span><br \/>\n    BLUE_OR_GREEN&#061;<span class=\"token string\">&#034;&#034;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  agent any <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5b9a\u4e49\u5728\u54ea\u4e2a agent \u4e0a\u8fd0\u884c&#xff0c;\u8fd9\u91cc\u4f7f\u7528\u4efb\u610f\u53ef\u7528\u8282\u70b9<br \/>\n  stages <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5b9a\u4e49\u6d41\u6c34\u7ebf\u4e2d\u5404\u4e2a\u9636\u6bb5&#xff08;stages&#xff09;<br \/>\n    stage<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Deply Parent&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u9879\u76ee\u6784\u5efa\u9636\u6bb5<br \/>\n            agent <span class=\"token punctuation\">{<\/span><br \/>\n                docker <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>\u6307\u5b9a\u4f7f\u7528 Docker \u4ee3\u7406\u8fd0\u884c<br \/>\n                    image <span class=\"token string\">&#039;registry.cn-hangzhou.aliyuncs.com\/acs\/maven:3-jdk-8&#039;<\/span><br \/>\n                    args <span class=\"token string\">&#039;-v $HOME\/.m2\/repository:\/root\/.m2\/repository -u root&#039;<\/span><br \/>\n                <span class=\"token punctuation\">}<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n            steps <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5b9a\u4e49\u8be5\u9636\u6bb5\u7684\u6b65\u9aa4&#xff08;steps&#xff09;&#xff0c;\u5e76\u4f7f\u7528 script \u5757\u4ee5\u811a\u672c\u5f62\u5f0f\u6267\u884c\u547d\u4ee4<br \/>\n                script <span class=\"token punctuation\">{<\/span><br \/>\nFAILED_STAGE&#061;env<span class=\"token punctuation\">.<\/span>STAGE_NAME <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>\u5c06\u5f53\u524d\u9636\u6bb5\u540d\u79f0&#xff08;env<span class=\"token punctuation\">.<\/span>STAGE_NAME&#xff09;\u8d4b\u503c\u7ed9\u53d8\u91cf FAILED_STAGE&#xff0c;\u4ee5\u4fbf\u5728\u51fa\u9519\u65f6\u8bb0\u5f55\u662f\u54ea\u4e00\u9636\u6bb5\u5931\u8d25\u4e86\u3002<br \/>\n                    sh <span class=\"token string\">&#034;mvn -Dmaven.repo.local&#061;\/var\/jenkins_home\/jenkins_m2_repo -U install -Dmaven.test.skip&#061;true&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u6267\u884c\u4e00\u4e2a shell \u547d\u4ee4&#xff0c;\u901a\u8fc7 Maven \u8fdb\u884c\u9879\u76ee\u6784\u5efa&#xff1a;<span class=\"token operator\">&#8211;<\/span>Dmaven<span class=\"token punctuation\">.<\/span>repo<span class=\"token punctuation\">.<\/span>local&#061;<span class=\"token operator\">\/<\/span><span class=\"token keyword\">var<\/span><span class=\"token operator\">\/<\/span>jenkins_home<span class=\"token operator\">\/<\/span>jenkins_m2_repo \u6307\u5b9a Maven \u672c\u5730\u4ed3\u5e93\u8def\u5f84&#xff0c;<span class=\"token operator\">&#8211;<\/span>U \u8868\u793a\u5f3a\u5236\u66f4\u65b0 SNAPSHOT \u4f9d\u8d56&#xff0c;install \u547d\u4ee4\u7528\u4e8e\u6784\u5efa\u5e76\u5b89\u88c5\u9879\u76ee&#xff0c;<span class=\"token operator\">&#8211;<\/span>Dmaven<span class=\"token punctuation\">.<\/span>test<span class=\"token punctuation\">.<\/span>skip&#061;true \u5219\u8df3\u8fc7\u6d4b\u8bd5\u6267\u884c\u3002<br \/>\n                    <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u62f7\u8d1d\u5230\u5bb9\u5668\u5916<br \/>\n                    sh <span class=\"token string\">&#034;cp target\/analyzer-1.0.jar &#034;<\/span> <span class=\"token operator\">&#043;<\/span> parentWorkspace <span class=\"token operator\">&#043;<\/span><span class=\"token string\">&#034;\/analyzer-1.0.jar&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u6267\u884c\u4e00\u4e2a shell \u547d\u4ee4&#xff0c;\u5c06 target \u76ee\u5f55\u4e0b\u751f\u6210\u7684 analyzer<span class=\"token operator\">&#8211;<\/span>1<span class=\"token punctuation\">.<\/span>0<span class=\"token punctuation\">.<\/span>jar \u6587\u4ef6\u590d\u5236\u5230\u5916\u90e8\u7684\u5de5\u4f5c\u7a7a\u95f4\u8def\u5f84&#xff08;\u7531\u53d8\u91cf parentWorkspace \u6307\u5b9a&#xff09;\u3002<br \/>\n                <span class=\"token punctuation\">}<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    stage<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Building image&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>\u6784\u5efa\u955c\u50cf\u9636\u6bb5<br \/>\n      steps <span class=\"token punctuation\">{<\/span><br \/>\n        script <span class=\"token punctuation\">{<\/span><br \/>\n          FAILED_STAGE&#061;env<span class=\"token punctuation\">.<\/span>STAGE_NAME <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5c06\u5f53\u524d\u9636\u6bb5\u540d\u79f0\u8d4b\u503c\u7ed9 FAILED_STAGE&#xff0c;<br \/>\n          docker<span class=\"token punctuation\">.<\/span>build<span class=\"token punctuation\">(<\/span>registry<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u8c03\u7528 docker<span class=\"token punctuation\">.<\/span>build<span class=\"token punctuation\">(<\/span>registry<span class=\"token punctuation\">)<\/span> \u65b9\u6cd5&#xff0c;\u6839\u636e\u4e4b\u524d\u5b9a\u4e49\u7684 registry \u53d8\u91cf\u6784\u5efa Docker \u955c\u50cf\u3002<br \/>\n          sh <span class=\"token string\">&#034;docker rmi -f ${registry}:<span class=\"token variable\">$GIT_COMMIT<\/span>&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5f3a\u5236\u5220\u9664\u672c\u5730\u955c\u50cf<br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n      <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    stage<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Deploy Image&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u90e8\u7f72\u955c\u50cf\u9636\u6bb5<br \/>\n      steps <span class=\"token punctuation\">{<\/span><br \/>\n        script <span class=\"token punctuation\">{<\/span><br \/>\n          FAILED_STAGE&#061;env<span class=\"token punctuation\">.<\/span>STAGE_NAME <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5c06\u5f53\u524d\u9636\u6bb5\u540d\u79f0\u8d4b\u503c\u7ed9 FAILED_STAGE<br \/>\n          docker<span class=\"token punctuation\">.<\/span>withRegistry<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;https:\/\/registry-vpc.cn-shanghai.aliyuncs.com&#039;<\/span><span class=\"token punctuation\">,<\/span> registryCredential<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u4f7f\u7528 docker<span class=\"token punctuation\">.<\/span>withRegistry \u65b9\u6cd5\u6307\u5b9a\u955c\u50cf\u4ed3\u5e93\u5730\u5740 https:<span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>registry<span class=\"token operator\">&#8211;<\/span>vpc<span class=\"token punctuation\">.<\/span>cn<span class=\"token operator\">&#8211;<\/span>shanghai<span class=\"token punctuation\">.<\/span>aliyuncs<span class=\"token punctuation\">.<\/span>com \u548c\u51ed\u636e registryCredential&#xff0c;<br \/>\n            docker<span class=\"token punctuation\">.<\/span>image<span class=\"token punctuation\">(<\/span>registry<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>push<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;<span class=\"token variable\">$GIT_COMMIT<\/span>&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>\u5c06\u6784\u5efa\u7684\u955c\u50cf\u4ee5\u5f53\u524d Git \u63d0\u4ea4\u53f7&#xff08;<span class=\"token variable\">$GIT_COMMIT<\/span>&#xff09;\u4f5c\u4e3a\u6807\u7b7e\u63a8\u9001\u5230\u4ed3\u5e93\u3002<br \/>\n          <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n      <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    stage<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Update k8s cluster&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u66f4\u65b0 Kubernetes \u96c6\u7fa4\u9636\u6bb5<br \/>\n          options <span class=\"token punctuation\">{<\/span><br \/>\n            timeout<span class=\"token punctuation\">(<\/span>time: 5<span class=\"token punctuation\">,<\/span> unit: <span class=\"token string\">&#039;MINUTES&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u672c\u9636\u6bb5\u8d85\u65f6\u65f6\u95f4\u9650\u5b9a\u4e3a 5 \u5206\u949f<br \/>\n          <span class=\"token punctuation\">}<\/span><br \/>\n          steps <span class=\"token punctuation\">{<\/span><br \/>\n            script <span class=\"token punctuation\">{<\/span><br \/>\n              FAILED_STAGE&#061;env<span class=\"token punctuation\">.<\/span>STAGE_NAME <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5f53\u524d\u9636\u6bb5\u540d\u79f0\u8d4b\u503c\u7ed9 FAILED_STAGE<br \/>\n              <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>env<span class=\"token punctuation\">.<\/span>GIT_BRANCH &#061;&#061; <span class=\"token string\">&#034;origin\/test&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5224\u65ad\u5f53\u524d\u7684 Git \u5206\u652f\u662f\u5426\u4e3a <span class=\"token string\">&#034;origin\/test&#034;<\/span>&#xff0c;\u5206\u652f\u9700\u8981\u6309\u9700\u9009\u62e9&#xff0c;\u8fd9\u91cc\u662f\u5728test\u5206\u652f\u4e0b&#xff0c;\u4f7f\u7528\u4f7f\u7528test&#xff0c;\u4e5f\u53ef\u4ee5\u6539\u4e3amaster\u7b49\u3002<br \/>\n                sh <span class=\"token string\">&#034;cat k8s\/deployment.yml | sed &#039;s\/{{GIT_COMMIT}}\/<span class=\"token variable\">$GIT_COMMIT<\/span>\/g&#039; | kubectl apply -n default -f -&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u4f7f\u7528 sed \u547d\u4ee4\u5c06 k8s<span class=\"token operator\">\/<\/span>deployment<span class=\"token punctuation\">.<\/span>yml \u6587\u4ef6\u4e2d\u7684\u5360\u4f4d\u7b26 <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">{<\/span>GIT_COMMIT<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">}<\/span> \u66ff\u6362\u4e3a\u5b9e\u9645\u7684 Git \u63d0\u4ea4\u53f7&#xff0c;\u5e76\u901a\u8fc7\u7ba1\u9053\u4f20\u9012\u7ed9 kubectl apply \u547d\u4ee4&#xff0c;\u5e94\u7528\u4e8e default \u547d\u540d\u7a7a\u95f4<br \/>\n                sh <span class=\"token string\">&#034;kubectl rollout status deployment\/aaa -n default&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u4f7f\u7528 kubectl rollout status \u547d\u4ee4\u68c0\u67e5\u90e8\u7f72\u72b6\u6001&#xff0c;\u786e\u4fdd\u90e8\u7f72\u6210\u529f<br \/>\n              <span class=\"token punctuation\">}<\/span><span class=\"token keyword\">else<\/span><span class=\"token punctuation\">{<\/span><br \/>\n                sh <span class=\"token string\">&#034;cat k8s\/deployment-test.yml | sed &#039;s\/{{GIT_COMMIT}}\/<span class=\"token variable\">$GIT_COMMIT<\/span>\/g&#039; | kubectl apply -n test -f -&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5bf9 k8s<span class=\"token operator\">\/<\/span>deployment<span class=\"token operator\">&#8211;<\/span>test<span class=\"token punctuation\">.<\/span>yml \u6587\u4ef6\u8fdb\u884c\u66ff\u6362&#xff0c;\u5e76\u5c06\u5176\u5e94\u7528\u4e8e test \u547d\u540d\u7a7a\u95f4<br \/>\n                sh <span class=\"token string\">&#034;kubectl rollout status deployment\/aaa -n default&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u68c0\u67e5\u90e8\u7f72\u72b6\u6001<br \/>\n              <span class=\"token punctuation\">}<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n          <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  post <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u6d41\u6c34\u7ebf\u7684\u540e\u7f6e\u64cd\u4f5c&#xff08;post&#xff09;<br \/>\n      aborted <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u6d41\u6c34\u7ebf\u88ab\u4e2d\u6b62&#xff08;aborted&#xff09;\u65f6&#xff0c;\u6267\u884c\u4ee5\u4e0b script \u811a\u672c<br \/>\n        script <span class=\"token punctuation\">{<\/span><br \/>\n          <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>FAILED_STAGE &#061;&#061; <span class=\"token string\">&#034;Update k8s cluster&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5982\u679c\u6700\u540e\u51fa\u9519\u7684\u9636\u6bb5&#xff08;FAILED_STAGE&#xff09;\u662f <span class=\"token string\">&#034;Update k8s cluster&#034;<\/span>&#xff0c;\u5219\u6839\u636e\u5f53\u524d Git \u5206\u652f\u8fdb\u884c\u56de\u6eda\u64cd\u4f5c<br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>env<span class=\"token punctuation\">.<\/span>GIT_BRANCH &#061;&#061; <span class=\"token string\">&#034;origin\/test&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5982\u679c\u5728 origin<span class=\"token operator\">\/<\/span>test \u5206\u652f\u4e0b&#xff0c;\u5206\u652f\u9700\u8981\u6309\u9700\u9009\u62e9&#xff0c;\u8fd9\u91cc\u662f\u5728test\u5206\u652f\u4e0b&#xff0c;\u4f7f\u7528\u4f7f\u7528test&#xff0c;\u4e5f\u53ef\u4ee5\u6539\u4e3amaster\u7b49\u3002<br \/>\n              sh <span class=\"token string\">&#034;kubectl config use kubernetes&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u5207\u6362 kubectl \u914d\u7f6e&#xff09;<br \/>\n              sh <span class=\"token string\">&#034;kubectl rollout undo deployment\/aaa&#034;<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span> \u56de\u6eda\u90e8\u7f72 aaa\u3002<br \/>\n            <span class=\"token punctuation\">}<\/span><span class=\"token keyword\">else<\/span><span class=\"token punctuation\">{<\/span><br \/>\n              sh <span class=\"token string\">&#034;kubectl config use kubernetes&#034;<\/span> \u5207\u6362\u914d\u7f6e<br \/>\n              sh <span class=\"token string\">&#034;kubectl rollout undo deployment\/aaa-test&#034;<\/span> \u56de\u6eda\u90e8\u7f72<br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n          <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n      <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h3>\u516d\u3001\u521b\u5efa\u4efb\u52a1<\/h3>\n<p>\u521b\u5efa\u4e00\u4e2a\u4efb\u52a1&#xff08;\u53ef\u4ee5\u4f7f\u7528\u6a21\u677f&#xff0c;\u5982Freestyle project\u3001Pipeline&#xff09;\u3002<\/p>\n<li>\u5982\u679c\u4f7f\u7528\u7684\u662fFreestyle project\n<li>\u9009\u62e9\u4ee3\u7801\u6e90\u7ba1\u7406&#xff08;Source Code Management&#xff09;&#xff0c;\u9879\u76ee\u5982\u679c\u5728Coding\u3001GitHub\u3001Gitee\u7b49\u6258\u7ba1\u5e73\u53f0\u4e0a&#xff0c;\u5219\u9009\u62e9Git\u3002\n<li>\u586b\u5199\u4ed3\u5e93\u8def\u5f84&#xff08;Repository URL&#xff09;&#xff0c;HTTP\u7684\u4ed3\u5e93\u8def\u5f84\u3002\u586b\u5199\u5b8c\u8def\u5f84\u4ee5\u540e&#xff0c;\u4e00\u822c\u4f1a\u62a5\u9519\u3002<\/li>\n<li>\u5982\u679c\u6ca1\u6709Credentials&#xff0c;\u5219\u9700\u8981\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684Credentials\u3002\u6dfb\u52a0\u65f6&#xff0c;Username \u586b\u4ed3\u5e93\u6240\u5728\u5e73\u53f0\u7684\u90ae\u7bb1&#xff0c;\u5bc6\u7801\u586b\u4ed3\u5e93\u6240\u5728\u5e73\u53f0\u7684\u7528\u6237\u5bc6\u7801\u3002\u5b8c\u6210\u4ee5\u540e&#xff0c;\u5982\u679c\u8d26\u53f7\u5bc6\u7801\u6ca1\u95ee\u9898&#xff0c;\u5219\u6b64\u5904\u4e0d\u4f1a\u62a5\u9519\u3002<\/li>\n<li>\u6709\u65f6\u8fd8\u9700\u8981\u9009\u62e9\u5206\u652f&#xff08;Branch Specifier&#xff09;\u3002<\/li>\n<\/li>\n<li>\u5904\u7406\u6784\u5efa\u6d41\u7a0b&#xff08;Steps&#xff09;&#xff0c;\u9700\u8981\u624b\u52a8\u4e00\u4e2a\u4e00\u4e2a\u6dfb\u52a0&#xff08;Add build step&#xff09;\u3002<\/li>\n<\/li>\n<li>\u5982\u679c\u4f7f\u7528\u7684\u662fPipeline\n<li>\u4e00\u822c\u9009\u62e9Pipeline-Definition\u4e3aPipeline script from SCM\u3002<\/li>\n<li>SCM &#xff08;\u4ee3\u7801\u6e90&#xff09;\u9009\u62e9\u4e3a Git\n<li>\u586b\u5199\u4ed3\u5e93\u8def\u5f84&#xff08;Repository URL&#xff09;&#xff0c;HTTP\u7684\u4ed3\u5e93\u8def\u5f84\u3002\u586b\u5199\u5b8c\u8def\u5f84\u4ee5\u540e&#xff0c;\u4e00\u822c\u4f1a\u62a5\u9519\u3002<\/li>\n<li>\u5982\u679c\u6ca1\u6709Credentials&#xff0c;\u5219\u9700\u8981\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684Credentials\u3002\u6dfb\u52a0\u65f6&#xff0c;Username \u586b\u4ed3\u5e93\u6240\u5728\u5e73\u53f0\u7684\u90ae\u7bb1&#xff0c;\u5bc6\u7801\u586b\u4ed3\u5e93\u6240\u5728\u5e73\u53f0\u7684\u7528\u6237\u5bc6\u7801\u3002\u5b8c\u6210\u4ee5\u540e&#xff0c;\u5982\u679c\u8d26\u53f7\u5bc6\u7801\u6ca1\u95ee\u9898&#xff0c;\u5219\u6b64\u5904\u4e0d\u4f1a\u62a5\u9519\u3002<\/li>\n<li>\u6709\u65f6\u8fd8\u9700\u8981\u9009\u62e9\u5206\u652f&#xff08;Branch Specifier&#xff09;\u3002<\/li>\n<\/li>\n<li>Script Path\u586b\u5199\u81ea\u5df1\u5728\u9879\u76ee\u6839\u76ee\u5f55\u653e\u7f6e\u7684\u7528\u4e8ejenkins\u8bfb\u53d6\u7684\u6587\u4ef6&#xff08;\u81ea\u52a8\u5316\u90e8\u7f72\u7684\u547d\u4ee4&#xff09;&#xff0c;\u5982jenkinsfile\u6587\u4ef6\u7b49\u3002<\/li>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb721\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72_docker jenkins\u81ea\u52a8\u5316\u90e8\u7f72<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1492,27,392,1493,43,395],"topic":[],"class_list":["post-19475","post","type-post","status-publish","format-standard","hentry","category-server","tag-1492","tag-docker","tag-jenkins","tag-k8s","tag-43","tag-395"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/19475.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb721\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72_docker jenkins\u81ea\u52a8\u5316\u90e8\u7f72\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/19475.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T17:48:34+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/19475.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/19475.html\",\"name\":\"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T17:48:34+00:00\",\"dateModified\":\"2025-04-18T17:48:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/19475.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/19475.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/19475.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/19475.html","og_locale":"zh_CN","og_type":"article","og_title":"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb721\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72_docker jenkins\u81ea\u52a8\u5316\u90e8\u7f72","og_url":"https:\/\/www.wsisp.com\/helps\/19475.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T17:48:34+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/19475.html","url":"https:\/\/www.wsisp.com\/helps\/19475.html","name":"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T17:48:34+00:00","dateModified":"2025-04-18T17:48:34+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/19475.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/19475.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/19475.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"02_\u4f7f\u7528Docker\u5728\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Jekins\u5b9e\u73b0\u9879\u76ee\u7684\u81ea\u52a8\u5316\u90e8\u7f72"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/19475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=19475"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/19475\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=19475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=19475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=19475"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=19475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}