{"id":15608,"date":"2025-04-18T22:08:07","date_gmt":"2025-04-18T14:08:07","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/15608.html"},"modified":"2025-04-18T22:08:07","modified_gmt":"2025-04-18T14:08:07","slug":"%e9%83%a8%e7%bd%b2gitlab%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/15608.html","title":{"rendered":"\u90e8\u7f72GitLab\u670d\u52a1\u5668"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>\u73af\u5883\u51c6\u5907<\/li>\n<li>GitLab<\/li>\n<li>\u90e8\u7f72GitLab\u670d\u52a1\u5668<\/li>\n<li>GitLab\u4e2d\u4e3b\u8981\u7684\u6982\u5ff5<\/li>\n<li>\u5ba2\u6237\u7aef\u4e0a\u4f20\u4ee3\u7801\u5230gitlab\u670d\u52a1\u5668<\/li>\n<li>CI-CD\u6982\u8ff0<\/li>\n<li>\n<ul>\n<li>\u8f6f\u4ef6\u7a0b\u5e8f\u4e0a\u7ebf\u6d41\u7a0b<\/li>\n<li>\u5b89\u88c5Jenkins\u670d\u52a1\u5668<\/li>\n<\/ul>\n<\/li>\n<li>\u914d\u7f6ejenkins<\/li>\n<li>\u8f6f\u4ef6\u7248\u672c\u7ba1\u7406<\/li>\n<li>\u914d\u7f6ejenkins\u8bbf\u95eegitlab\u8fdc\u7a0b\u4ed3\u5e93<\/li>\n<li>\u4e0b\u8f7d\u5230\u5b50\u76ee\u5f55<\/li>\n<li>\u90e8\u7f72\u4ee3\u7801\u5230web\u670d\u52a1\u5668<\/li>\n<li>\n<ul>\n<li>\u81ea\u52a8\u5316\u90e8\u7f72\u6d41\u7a0b<\/li>\n<\/ul>\n<\/li>\n<li>\u914d\u7f6e\u5171\u4eab\u670d\u52a1\u5668<\/li>\n<li>\n<ul>\n<li>\u914d\u7f6ejenkins\u628agitlab\u4e0b\u8f7d\u7684\u4ee3\u7801\u6253\u5305<\/li>\n<\/ul>\n<\/li>\n<li>web\u670d\u52a1\u81ea\u52a8\u90e8\u7f72<\/li>\n<li>\n<ul>\n<li>\u7f16\u5199\u81ea\u52a8\u4e0a\u7ebf\u811a\u672c<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u73af\u5883\u51c6\u5907<\/h3>\n<ul>\n<li>\u672c\u5b9e\u9a8c\u91c7\u7528\u534e\u4e3a\u4e91ECS\u8fdb\u884c&#xff0c;\u6a21\u62df\u771f\u5b9e\u5de5\u4f5c\u73af\u5883<\/li>\n<li>\u5f53\u7136\u672c\u5730\u7535\u8111\u73af\u5883\u914d\u7f6e\u8fbe\u6807&#xff0c;\u4e5f\u53ef\u4ee5\u5728\u672c\u5730\u7535\u8111\u4f7f\u7528VMware\u865a\u62df\u673a\u5b8c\u6210<\/li>\n<li>\u672c\u5b9e\u9a8c\u4f9b\u97004\u53f0\u4e91\u4e3b\u673a&#xff0c;\u5168\u90e8\u4f7f\u7528Rocky Linux8.5\u64cd\u4f5c\u7cfb\u7edf&#xff0c;2vCPU&#xff0c;4G\u5185\u5b58<\/li>\n<li>\u5177\u4f53\u8981\u6c42\u5982\u4e0b&#xff1a;<\/li>\n<\/ul>\n<table>\n<tr>\u4e3b\u673a\u540dIP\u5730\u5740\u914d\u7f6e\u89d2\u8272<\/tr>\n<tbody>\n<tr>\n<td align=\"center\">windows<\/td>\n<td align=\"center\">\u2013<\/td>\n<td align=\"center\">\u2013<\/td>\n<td align=\"center\">\u7a0b\u5e8f\u5458<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">develop<\/td>\n<td align=\"center\">192.168.0.10|\u516c\u7f51IP<\/td>\n<td align=\"center\">2vCPU&#xff0c;4G\u5185\u5b58<\/td>\n<td align=\"center\">\u7a0b\u5e8f\u5458<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">gitlab<\/td>\n<td align=\"center\">192.168.0.20|\u516c\u7f51IP<\/td>\n<td align=\"center\">2vCPU&#xff0c;4G\u5185\u5b58<\/td>\n<td align=\"center\">\u8fdc\u7a0b\u4ed3\u5e93<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">jenkins<\/td>\n<td align=\"center\">192.168.0.30|\u516c\u7f51IP<\/td>\n<td align=\"center\">2vCPU&#xff0c;4G\u5185\u5b58<\/td>\n<td align=\"center\">CI\/CD\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">web1<\/td>\n<td align=\"center\">192.168.0.40|\u516c\u7f51IP<\/td>\n<td align=\"center\">2vCPU&#xff0c;4G\u5185\u5b58<\/td>\n<td align=\"center\">web\u670d\u52a1\u5668<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9879\u76ee\u67b6\u6784\u56fe<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140758-68025cbe2265d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>GitLab<\/h3>\n<ul>\n<li>\n<p>\u5b83\u662f\u4e00\u4e2a\u5f00\u6e90\u7684git\u4ed3\u5e93\u670d\u52a1\u5668\u3002\u7528\u4e8e\u5b9e\u73b0\u4ee3\u7801\u96c6\u4e2d\u6258\u7ba1<\/p>\n<\/li>\n<li>\n<p>\u5206\u4e3a\u4f01\u4e1a\u7248\u548cCE\u793e\u533a\u7248<\/p>\n<\/li>\n<li>\n<p>\u90e8\u7f72\u65b9\u5f0f&#xff1a;\u8f6f\u4ef6\u5305\u90e8\u7f72\u3001\u5bb9\u5668\u90e8\u7f72<\/p>\n<\/li>\n<\/ul>\n<h3>\u90e8\u7f72GitLab\u670d\u52a1\u5668<\/h3>\n<ul>\n<li>\u4e91\u4e3b\u673a192.168.0.20&#xff0c;\u8fdc\u7a0b\u8fde\u63a5\u65f6\u9700\u8981\u8fde\u63a5\u5176\u5bf9\u5e94\u7684\u516c\u7f51IP\u5730\u5740<\/li>\n<li>\u5c062024-AI\u5927\u6a21\u578bJava\u5168\u94fe\u8def\u5de5\u7a0b\u5e08\u73af\u5883\u8d44\u6599\/\u7b2c\u56db\u6a21\u5757\/gitlab_zh.tar\u62f7\u8d1d\u5230gitlab\u670d\u52a1\u5668\u7684\/root<\/li>\n<li>\u5c062024-AI\u5927\u6a21\u578bJava\u5168\u94fe\u8def\u5de5\u7a0b\u5e08\u73af\u5883\u8d44\u6599\/\u7b2c\u56db\u6a21\u5757\/docker\u6587\u4ef6\u5939\u62f7\u8d1d\u5230gitlab\u670d\u52a1\u5668\u7684\/root<\/li>\n<li>\u901a\u8fc7\u5bb9\u5668\u90e8\u7f72GitLab\u670d\u52a1<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd \/root\/docker<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab docker<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y localinstall *.rpm#\u5b89\u88c5\u5bb9\u5668\u7ba1\u7406\u8f6f\u4ef6docker<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab docker<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y install bash-completion#\u5b89\u88c5tab\u952e&#xff08;\u5237\u65b0\u751f\u6548&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl start docker #\u542f\u52a8\u670d\u52a1<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable docker#\u5c06\u670d\u52a1\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u542f <\/span><\/p>\n<p>\u4fee\u6539gitlab\u670d\u52a1\u5668\u7684\u7684sshd\u670d\u52a1\u7aef\u53e3\u53f7\u4e3a8022&#xff0c;\u56e0\u4e3agitlab\u5bb9\u5668\u4e5f\u8981\u7528\u523022\u7aef\u53e3&#xff0c;\u6709\u51b2\u7a81\u3002<\/p>\n<p>vim &#043;17\u662f\u6307\u6253\u5f00\u914d\u7f6e\u6587\u4ef6\u65f6&#xff0c;\u5149\u6807\u76f4\u63a5\u5b9a\u4f4d\u5230\u7b2c17\u884c\u3002<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim &#043;17 \/etc\/ssh\/sshd_config #\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/span><br \/>\n<span class=\"token number\">17<\/span> Port <span class=\"token number\">8022<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart sshd#\u91cd\u542fsshd\u8fdc\u7a0b\u7ba1\u7406\u670d\u52a1<\/span><br \/>\n<span class=\"token comment\">#\u91cd\u542f\u4e4b\u540e\u9700\u8981\u4f7f\u7528\u8fdc\u7a0b\u5de5\u5177\u91cd\u65b0\u8fde\u63a5gitlab\u670d\u52a1\u5668&#xff0c;\u5e76\u4e14\u6307\u5b9a8022\u7aef\u53e3\u53f7<\/span><\/p>\n<p>gitlab\u5bb9\u5668\u8fd0\u884c\u9700\u8981\/etc\/resolv.conf\u6587\u4ef6&#xff0c;\u5982\u679c\u8be5\u6587\u4ef6\u5df2\u5b58\u5728&#xff0c;\u5219\u65e0\u9700\u521b\u5efa<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># touch \/etc\/resolv.conf<\/span><\/p>\n<ul>\n<li>\u5bfc\u5165\u955c\u50cf\n<ul>\n<li>\u4e00\u4e2a\u955c\u50cf\u53ef\u4ee5\u521b\u5efa\u5f88\u591a\u5bb9\u5668\u3002\u955c\u50cf\u662f\u53ea\u8bfb\u7684&#xff0c;\u5bb9\u5668\u662f\u53ef\u4ee5\u6539\u53d8\u7684\u3002<\/li>\n<li>\u5bb9\u5668\u76f8\u5f53\u4e8e\u662f\u7cbe\u7b80\u7684\u865a\u62df\u673a&#xff0c;\u53ef\u4ee5\u50cf\u865a\u62df\u673a\u4e00\u6837&#xff0c;\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker load &lt; \/root\/gitlab_zh.tar<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker images#\u67e5\u770b\u955c\u50cf\u662f\u5426\u5bfc\u5165<\/span><\/p>\n<ul>\n<li>\u4fdd\u969c\u6570\u636e\u5b8c\u6574\u6027\n<ul>\n<li>\u4e3a\u4e86\u5220\u5bb9\u5668&#xff0c;\u4e0d\u4e22\u5931\u6570\u636e&#xff0c;\u9700\u8981\u628a\u5bb9\u5668\u9700\u8981\u7684\u6570\u636e\u4fdd\u5b58\u5728\u5bbf\u4e3b\u673a\u4e0a\u3002<\/li>\n<li>\u5728\u54ea\u53f0\u4e3b\u673a\u4e0a\u542f\u52a8\u5bb9\u5668&#xff0c;\u54ea\u53f0\u4e3b\u673a\u5c31\u662f\u5bbf\u4e3b\u673a\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir -p \/srv\/gitlab\/{config,logs,data}#\u521b\u5efa\u6301\u4e45\u5316\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls \/srv\/gitlab\/<\/span><br \/>\nconfig data logs<\/p>\n<ul>\n<li>\u521b\u5efa\u5bb9\u5668\n<ul>\n<li>-d\u540e\u53f0\u8fd0\u884c<\/li>\n<li>-h gitlab\u8bbe\u7f6e\u5bb9\u5668\u7684\u4e3b\u673a\u540d<\/li>\n<li>\u2013name gitlab\u662fdocker ps\u67e5\u770b\u5230\u7684\u5bb9\u5668\u540d<\/li>\n<li>-p\u6307\u5b9a\u53d1\u5e03\u7684\u7aef\u53e3\u53f7&#xff0c;\u5f53\u8bbf\u95ee\u5bbf\u4e3b\u673a443\/80\/22\u7aef\u53e3\u65f6&#xff0c;\u8fd9\u6837\u7684\u8bf7\u6c42\u5c31\u53d1\u7ed9\u5bb9\u5668\u7684\u76f8\u5173\u7aef\u53e3<\/li>\n<li>\u2013restart always\u662f\u5f00\u673a\u81ea\u542f<\/li>\n<li>-v\u662f\u6620\u5c04\u8def\u5f84&#xff0c;\u5c06\u5bb9\u5668\u4e2d\u6307\u5b9a\u7684\u8def\u5f84&#xff0c;\u6620\u5c04\u5230\u5bbf\u4e3b\u673a&#xff0c;\u4ee5\u4fbf\u4fdd\u5b58\u5bb9\u5668\u4ea7\u751f\u7684\u6570\u636e<\/li>\n<li>\u6700\u540e\u7684gitlab_zh\u662f\u955c\u50cf\u540d<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker run -d -h gitlab &#8211;name gitlab -p 443:443 -p 80:80 -p 22:22 &#8211;restart always -v \/srv\/gitlab\/config:\/etc\/gitlab -v \/srv\/gitlab\/logs:\/var\/log\/gitlab -v \/srv\/gitlab\/data:\/var\/opt\/gitlab gitlab_zh<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker ps#\u67e5\u770b\u5bb9\u5668\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668<\/span><br \/>\n<span class=\"token comment\"># \u5982\u679c\u4e00\u5207\u6b63\u5e38&#xff0c;\u51e0\u5206\u949f\u540e&#xff0c;\u53ef\u4ee5\u8bbf\u95eehttp:\/\/gitlab\u670d\u52a1\u5668\u7684\u516c\u7f51ip\/ (\u4ee5\u81ea\u5df1\u4e3a\u51c6)<\/span><br \/>\n<span class=\"token comment\"># \u4f8b\u5982&#xff1a;http:\/\/121.36.66.101\/<\/span><\/p>\n<p>\u9644&#xff1a;\u5982\u679c\u5bb9\u542f\u52a8\u5931\u8d25&#xff0c;\u518d\u6b21\u521b\u5efa\u6709\u4ee5\u4e0b\u9519\u8bef&#xff1a;<\/p>\n<p>Error: error creating container storage: the container name <span class=\"token string\">&#034;gitlab&#034;<\/span> is already <span class=\"token keyword\">in<\/span> use by <span class=\"token string\">&#034;ca425e33d7ff2\u7ed9i\u4ed6d282cbec1033023851cff285fe9b819ed50d47a08a875372fde&#034;<\/span><span class=\"token builtin class-name\">.<\/span> You have to remove that container to be able to reuse that name.: that name is already <span class=\"token keyword\">in<\/span> use<\/p>\n<p>\u5219&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker rm gitlab<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;gitlab ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker run -d -h gitlab &#8211;name gitlab -p 443:443 -p 80:80 -p 22:22 &#8211;restart always -v \/srv\/gitlab\/config:\/etc\/gitlab -v \/srv\/gitlab\/logs:\/var\/log\/gitlab -v \/srv\/gitlab\/data:\/var\/opt\/gitlab gitlab_zh<\/span><\/p>\n<p>\u914d\u7f6egitlab<\/p>\n<ul>\n<li>\u7b2c\u4e00\u6b21\u767b\u9646\u2011\u65f6&#xff0c;\u8981\u6c42\u6539\u5bc6\u7801\u3002\u5bc6\u7801\u9700\u8981\u662f\u590d\u6742\u5bc6\u7801&#xff0c;\u59821234.com\u3002\u4fee\u6539\u4e4b\u540e&#xff0c;\u767b\u9646\u7684<font color=\"blue\">\u7528\u6237\u540d\u662froot<\/font>\u3002<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140758-68025cbe5dd4d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140758-68025cbea2a97.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u4fee\u6539\u5916\u89c2\u8bbe\u7f6e<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140758-68025cbee8530.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140759-68025cbf6ddad.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140800-68025cc0042fa.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140800-68025cc08881b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u70b9\u51fb\u5934\u50cf\u2013&gt;\u9000\u51fa&#xff0c;\u91cd\u65b0\u767b\u5f55\u9a8c\u8bc1<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140801-68025cc11dda8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140801-68025cc143082.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>GitLab\u4e2d\u4e3b\u8981\u7684\u6982\u5ff5<\/h3>\n<ul>\n<li>\u7528\u6237&#xff1a;\u4e3a\u4f7f\u7528gitlab\u7684\u7528\u6237\u521b\u5efa\u7684\u8d26\u53f7\u3002<\/li>\n<li>\u7ec4&#xff1a;\u7528\u6237\u7684\u96c6\u5408&#xff0c;\u53ef\u4ee5\u4e3a\u90e8\u95e8\u521b\u5efa\u7ec4\u3002\u5c06\u6765\u53ef\u4ee5\u5728\u9879\u76ee\u4e0a\u4e3a\u7ec4\u6388\u6743&#xff0c;\u7ec4\u4e2d\u6240\u6709\u7684\u7528\u6237\u90fd\u4f1a\u5f97\u5230\u76f8\u5e94\u7684\u6743\u9650\u3002<\/li>\n<li>\u9879\u76ee&#xff1a;\u7528\u4e8e\u4fdd\u5b58\u4ee3\u7801\u6587\u4ef6\u7684\u7a7a\u95f4\u3002<\/li>\n<li>\u7528\u6237\u3001\u7ec4\u3001\u9879\u76ee\u4e4b\u95f4\u7684\u5173\u7cfb\u5982\u4e0b<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140801-68025cc1cf553.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u521b\u5efa\u7528\u6237\n<ul>\n<li>\u7528\u6237\u540d&#xff1a;jerry<\/li>\n<li>\u5bc6\u7801&#xff1a;1234.com<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140802-68025cc22277c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u586b\u5199\u622a\u56fe\u4e0a\u7684\u51e0\u9879\u540e&#xff0c;\u5176\u4ed6\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e&#xff0c;\u70b9\u4fdd\u5b58\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140802-68025cc2ab549.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140803-68025cc34564d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u521b\u5efa\u597d\u7528\u6237\u540e&#xff0c;\u70b9\u51fb\u7f16\u8f91&#xff0c;\u53ef\u4ee5\u4e3a\u4ed6\/\u5979\u8bbe\u7f6e\u5bc6\u7801&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140803-68025cc3c9a33.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140804-68025cc464f51.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140804-68025cc4f3af2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140805-68025cc58dddf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\n<p>\u4fdd\u5b58\u4fee\u6539\u540e&#xff0c;\u9000\u51fa\u5f53\u524d\u8d26\u53f7&#xff0c;\u4f7f\u7528\u65b0\u8d26\u53f7jerry\u4e0e\u5176\u5bc6\u78011234.com\u767b\u9646\u6d4b\u8bd5\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e00\u6b21\u767b\u9646\u65f6&#xff0c;\u4e5f\u662f\u8981\u6c42\u4fee\u6539\u5bc6\u7801&#xff0c;\u65b0\u5bc6\u7801\u53ef\u4ee5\u8bbe\u7f6e\u4e0e\u65e7\u5bc6\u7801\u4e00\u6837\u3002<\/p>\n<\/li>\n<li>\n<p>\u65b0\u5efa\u7684jerry\u7528\u6237\u56e0\u4e3a\u6743\u9650\u8f83\u5c0f&#xff0c;\u6240\u4ee5\u770b\u5230\u7684\u754c\u9762&#xff0c;\u6ca1\u6709root\u7684\u529f\u80fd\u591a\u3002<\/p>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140806-68025cc61efea.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140806-68025cc6454fc.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140806-68025cc6bbfc1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18d1j4bm3jnqx.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u521b\u5efa\u7ec4,\u6ce8\u610f&#xff0c;\u9700\u8981\u4f7f\u7528root\u8d26\u53f7\u521b\u5efa&#xff0c;\u8fd9\u91cc\u9700\u8981\u5207\u6362\u56deroot\u8d26\u6237<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18dki4phwx2cd.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-184a5nhkmnurj.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18skoorjf5nyc.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5c06jerry\u7528\u6237\u52a0\u5230devops\u7ec4\u4e2d&#xff0c;\u89d2\u8272\u662f&#034;\u4e3b\u7a0b\u5e8f\u5458&#034;<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18vpc1a2my5ix.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u521b\u5efa\u9879\u76ee&#xff0c;\u7ba1\u7406\u5458root\u64cd\u4f5c<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18md250l0of5e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18jruhh3ccbiv.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5207\u6362\u4e3ajerry\u7528\u6237&#xff0c;\u67e5\u770b\u9879\u76ee\u662f\u5426\u8d1f\u8d23<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18ptou2wx5zoj.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18ibfprbngy5t.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18hiq3xnm51b3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18qzpfdrmmkdd.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u5ba2\u6237\u7aef\u4e0a\u4f20\u4ee3\u7801\u5230gitlab\u670d\u52a1\u5668<\/h3>\n<ul>\n<li>\n<p>\u67e5\u770b\u9879\u76ee\u8def\u5f84&#xff0c;\u91c7\u7528http\u65b9\u5f0f\u4e0a\u4f20<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u9879\u76ee\u8bf4\u660e<\/p>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18hzl0xjuxmps.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5728\u5ba2\u6237\u7aefdevelop\u670d\u52a1\u5668&#xff08;192.168.0.10&#xff0c;\u8fde\u63a5\u5176\u516c\u7f51IP\u5730\u5740&#xff09;\u4e0a\u4e0b\u8f7d\u9879\u76ee&#xff0c;\u7f16\u5199\u4ee3\u7801\u5e76\u4e0a\u4f20<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;develop ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y install git#\u5b89\u88c5git\u5de5\u5177<\/span><\/p>\n<p>\u4ecegitlab\u670d\u52a1\u5668\u590d\u5236\u5730\u5740\u4e4b\u540e&#xff0c;\u9700\u8981\u5c06gitlab\u5355\u8bcd\u6539\u4e3a\u81ea\u5df1gitlab\u670d\u52a1\u5668\u7684\u516c\u7f51IP\u5730\u5740<\/p>\n<p>~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git clone http:\/\/121.36.66.101\/devops\/myproject.git#\u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls   #\u672c\u5730\u51fa\u73b0\u4e00\u4e2amyproject\u76ee\u5f55<\/span><br \/>\nmyproject<\/p>\n<p>windows\u5ba2\u6237\u7aef\u4e5f\u53ef\u4ee5\u4f7f\u7528git clone\u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93&#xff0c;\u63d0\u524d\u5b89\u88c5git\u5ba2\u6237\u7aef&#xff08;\u5b89\u88c5\u5305\u57282024-AI\u5927\u6a21\u578bJava\u5168\u94fe\u8def\u5de5\u7a0b\u5e08\u73af\u5883\u8d44\u6599\/\u7b2c\u56db\u6a21\u5757\/cicd\u4e2d&#xff09;<\/p>\n<p>\u5982\u679c\u662f\u521a\u521a\u5b89\u88c5\u7684git\u8f6f\u4ef6\u9700\u8981\u9996\u5148\u5b9a\u4e49\u5168\u5c40\u914d\u7f6e&#xff0c;\u65b9\u53ef\u7ee7\u7eed\u4f7f\u7528&#xff08;\u6267\u884c\u4e00\u6b21\u5373\u53ef&#xff09;<\/p>\n<p><span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> user.name <span class=\"token string\">&#034;jerry&#034;<\/span><br \/>\n<span class=\"token function\">git<\/span> config <span class=\"token parameter variable\">&#8211;global<\/span> user.email <span class=\"token string\">&#034;jerry&#064;tedu.cn&#034;<\/span><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18czt2unlkvy3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4f7f\u7528develop\u670d\u52a1\u5668\u7f16\u5199README.txt\u6587\u4ef6&#xff0c;\u5e76\u4e0a\u4f20\u81f3\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;develop ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd myproject\/<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim README.md<\/span><br \/>\nWelcome to my beautiful world<span class=\"token operator\">!<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git add .   #\u4fdd\u5b58\u5230\u6682\u5b58\u533a<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git commit -m &#034;init data&#034; #\u63d0\u4ea4\u81f3\u672c\u5730\u4ed3\u5e93<\/span><\/p>\n<p><span class=\"token comment\"># \u5c06master\u5206\u652f\u63a8\u9001\u5230origin\u4ed3\u5e93\u3002origin\u662f\u9ed8\u8ba4\u4ed3\u5e93\u540d\u3002<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git push -u origin master<\/span><br \/>\nUsername <span class=\"token keyword\">for<\/span> <span class=\"token string\">&#039;http:\/\/192.168.4.20&#039;<\/span><span class=\"token builtin class-name\">:<\/span> jerry   <span class=\"token comment\">#\u7528\u6237\u540d<\/span><br \/>\nPassword <span class=\"token keyword\">for<\/span> <span class=\"token string\">&#039;http:\/\/jerry&#064;192.168.4.20&#039;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token number\">1234<\/span>.com   <span class=\"token comment\">#\u5bc6\u7801(\u8f93\u5165\u4e0d\u663e\u793a)<\/span><br \/>\n<span class=\"token comment\"># \u5728\u670d\u52a1\u5668\u4e0a\u5237\u65b0web\u9875\u9762&#xff0c;\u53ef\u4ee5\u770b\u5230\u4ed3\u5e93\u4e2d\u5df2\u7ecf\u591a\u51fa\u4e86README.md\u6587\u4ef6<\/span><\/p>\n<p>\u91cd\u65b0\u64cd\u4f5c\u7f16\u5199\u4ee3\u7801&#xff0c;\u5e76\u63d0\u4ea4\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p><span class=\"token comment\"># \u5c06\u6765\u5c31\u53ef\u4ee5\u91cd\u5f97\u64cd\u4f5c&#xff1a;\u5199\u4ee3\u7801\u3001\u786e\u8ba4\u5230\u7248\u672c\u5e93\u3001\u4e0a\u4f20\u5230\u670d\u52a1\u5668<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cp \/etc\/hosts .<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git add .<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git commit -m &#034;add hosts&#034;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git push   #\u4e0d\u9700\u8981\u518d\u4f7f\u7528-u\u9009\u9879<\/span><br \/>\nUsername <span class=\"token keyword\">for<\/span> <span class=\"token string\">&#039;http:\/\/192.168.4.20&#039;<\/span><span class=\"token builtin class-name\">:<\/span> jerry<br \/>\nPassword <span class=\"token keyword\">for<\/span> <span class=\"token string\">&#039;http:\/\/jerry&#064;192.168.4.20&#039;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token number\">1234<\/span>.com<span class=\"token comment\">#\u5bc6\u7801(\u8f93\u5165\u4e0d\u663e\u793a)<\/span><br \/>\n<span class=\"token comment\"># \u5728\u670d\u52a1\u5668\u4e0a\u5237\u65b0web\u9875\u9762&#xff0c;\u53ef\u4ee5\u770b\u5230\u4ed3\u5e93\u4e2d\u5df2\u7ecf\u591a\u51fa\u4e86hosts\u6587\u4ef6<\/span><\/p>\n<p>\u53e6\u4e00\u4e2a\u5ba2\u6237\u7aefWindows\u62c9\u53d6\u65b0\u4ee3\u7801&#xff0c;\u5e76\u4e14\u4e0a\u4f20\u81ea\u5df1\u7684\u4ee3\u7801(\u9700\u8981windows\u5b89\u88c5\u597dgit\u5ba2\u6237\u7aef)<\/p>\n<p>$ git pull<span class=\"token comment\">#\u62c9\u53d6\u4ee3\u7801<\/span><br \/>\nremote: Counting objects: 6<span class=\"token punctuation\">,<\/span> done<span class=\"token punctuation\">.<\/span><br \/>\nremote: Compressing objects: 100% <span class=\"token punctuation\">(<\/span>4\/4<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> done<span class=\"token punctuation\">.<\/span><br \/>\nremote: Total 6 <span class=\"token punctuation\">(<\/span>delta 0<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> reused 0 <span class=\"token punctuation\">(<\/span>delta 0<span class=\"token punctuation\">)<\/span><br \/>\nUnpacking objects: 100% <span class=\"token punctuation\">(<\/span>6\/6<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> 515 bytes <span class=\"token punctuation\">|<\/span> 0 bytes\/s<span class=\"token punctuation\">,<\/span> done<span class=\"token punctuation\">.<\/span><br \/>\n<span class=\"token keyword\">From<\/span> http:<span class=\"token operator\">\/<\/span><span class=\"token operator\">\/<\/span>121<span class=\"token punctuation\">.<\/span>36<span class=\"token punctuation\">.<\/span>66<span class=\"token punctuation\">.<\/span>101\/devops\/myproject<br \/>\n <span class=\"token operator\">*<\/span> <span class=\"token namespace\">[new branch]<\/span>      master     <span class=\"token operator\">&#8211;<\/span>&gt; origin\/master<\/p>\n<p>Windows\u672c\u5730\u4ed3\u5e93\u4e2d\u5df2\u7ecf\u591a\u51fa\u4e86\u6570\u636e<\/p>\n<p><img decoding=\"async\" src=\"2025-04-182in20dytldg.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>Windows\u4e0a\u4f20\u6570\u636e\u81f3\u8fdc\u7a0b\u4ed3\u5e93&#xff0c;\u7f16\u5199win.txt\u6587\u4ef6&#xff0c;\u5185\u5bb9\u4e3a&#034;Here is Windows file.&#034;<\/p>\n<p>$ git add <span class=\"token punctuation\">.<\/span><span class=\"token comment\">#\u63d0\u4ea4\u6682\u5b58\u533a<\/span><br \/>\n$ git commit <span class=\"token operator\">&#8211;<\/span>m <span class=\"token string\">&#039;add Win.txt&#039;<\/span><span class=\"token comment\">#\u63d0\u4ea4\u672c\u5730\u4ed3\u5e93<\/span><br \/>\n$ git push <span class=\"token operator\">&#8211;<\/span>u origin master<span class=\"token comment\">#\u5c06master\u5206\u652f\u63a8\u9001\u5230origin\u4ed3\u5e93<\/span><br \/>\n<span class=\"token comment\"># \u5728\u670d\u52a1\u5668\u4e0a\u5237\u65b0web\u9875\u9762&#xff0c;\u53ef\u4ee5\u770b\u5230\u4ed3\u5e93\u4e2d\u5df2\u7ecf\u591a\u51fa\u4e86Win.txt\u6587\u4ef6<\/span><\/p>\n<p>develop\u670d\u52a1\u5668\u62c9\u53d6\u65b0\u4ee3\u7801&#xff0c;\u9a8c\u8bc1\u662f\u5426\u80fd\u591f\u540c\u6b65Win.txt<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;devlop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git pull<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;devlop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls#\u67e5\u770b\u591a\u51faWin.txt<\/span><br \/>\nhosts  README.md  Win.txt<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;devlop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cat Win.txt #\u5185\u5bb9\u6b63\u786e<\/span><br \/>\nHere is Windows file.<span class=\"token punctuation\">[<\/span>root&#064;devlop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># <\/span><\/p>\n<h3>CI-CD\u6982\u8ff0<\/h3>\n<ul>\n<li>CI&#xff1a;\u6301\u7eed\u96c6\u6210&#xff08;Continuous Integration&#xff09;<\/li>\n<li>CD&#xff1a;\u6301\u7eed\u4ea4\u4ed8&#xff08;Continuous Delivery\/Deployment&#xff09;<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18qbxkk3atutj.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>\u8f6f\u4ef6\u7a0b\u5e8f\u4e0a\u7ebf\u6d41\u7a0b<\/h4>\n<li>\u7a0b\u5e8f\u5458\u5c06\u4ee3\u7801\u4e0a\u4f20\u5230gitlab\u670d\u52a1\u5668<\/li>\n<li>SRE\u5de5\u7a0b\u5e08&#xff0c;\u901a\u8fc7jenkins\u670d\u52a1\u5668\u81ea\u52a8\u4e0b\u8f7dgitlab\u4e0a\u7684\u4ee3\u7801<\/li>\n<li>SRE\u5de5\u7a0b\u5e08\u7f16\u5199\u81ea\u52a8\u90e8\u7f72\u5230\u670d\u52a1\u5668\u4e0a\u7684\u811a\u672c<\/li>\n<h4>\u5b89\u88c5Jenkins\u670d\u52a1\u5668<\/h4>\n<ul>\n<li>jenkins\u670d\u52a1\u5668\u64cd\u4f5c&#xff08;192.168.0.30&#xff0c;\u9700\u8981\u8fdc\u7a0b\u5b83\u7684\u516c\u7f51IP\u5730\u5740&#xff09;<\/li>\n<\/ul>\n<p><span class=\"token comment\"># \u5b89\u88c5\u4f9d\u8d56\u5305<\/span><br \/>\n<span class=\"token comment\"># jenkins\u9700\u8981\u901a\u8fc7git\u4e0b\u8f7d\u4ee3\u7801&#xff0c;\u6240\u4ee5\u88c5git\u3002<\/span><br \/>\n<span class=\"token comment\"># jenkins\u662fjava\u7a0b\u5e8f&#xff0c;\u6240\u4ee5\u88c5java<\/span><br \/>\n<span class=\"token comment\"># postfix\u548cmailx\u662f\u90ae\u4ef6\u7a0b\u5e8f&#xff0c;jenkins\u53ef\u4ee5\u901a\u8fc7\u5b83\u4eec\u7ed9\u7ba1\u7406\u5458\u53d1\u90ae\u4ef6<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y install  git postfix mailx java-11-openjdk<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls#\u67e5\u770b\u662f\u5426\u4e0a\u4f20\u5b8c\u6bd5<\/span><br \/>\njenkins-2.263.1-1.1.noarch.rpm jenkins_plugins.tar.gz<\/p>\n<p>~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y localinstall  jenkins-2.263.1-1.1.noarch.rpm#\u5b89\u88c5jenkins<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl start jenkins#\u542f\u52a8jenkins\u670d\u52a1<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable jenkins#\u5c06jenkins\u670d\u52a1\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ss -nutlp | grep :8080#\u67e5\u770b\u7aef\u53e38080\u662f\u5426\u6b63\u5e38<\/span><\/p>\n<ul>\n<li>\u8bbf\u95eehttp:\/\/jenkins\u670d\u52a1\u5668\u516c\u7f51IP:8080&#xff0c;\u8fdb\u884c\u521d\u59cb\u5316<\/li>\n<\/ul>\n<p><span class=\"token comment\"># \u67e5\u770b\u521d\u59cb\u5316\u5bc6\u7801&#xff0c;\u6bcf\u4e2a\u4eba\u7684\u90fd\u4e0d\u4e00\u6837&#xff0c;\u8bf7\u4ee5\u81ea\u5df1\u7684\u4e3a\u51c6<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/span><br \/>\nb9d26edeef714940ab10aaa541081d90<\/p>\n<p>\u628a\u67e5\u770b\u5230\u7684\u5bc6\u7801\u7c98\u8d34\u5230\u6587\u672c\u6846\u4e2d&#xff0c;\u5982\u4e0b&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18kr5rc005fdr.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18mdkh1eypwkl.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18aj5r4txfqir.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u4e0d\u7528\u521b\u5efa\u7ba1\u7406\u5458&#xff0c;\u4f7f\u7528\u81ea\u5e26\u7684admin<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18e1vpkwqk2b2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18noscaglji0d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18bxop33a53bo.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u4fee\u6539admin\u5bc6\u7801<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18vo2lcaoc4m2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18k3eauk25mrt.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4f7f\u7528admin\u7528\u6237&#xff0c;\u5bc6\u7801123456\u767b\u5f55jenkins<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18sfpkf5zwpt2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u914d\u7f6ejenkins<\/h3>\n<ul>\n<li>\u5b89\u88c5\u63d2\u4ef6&#xff1a;jenkins\u7684\u5f88\u591a\u529f\u80fd\u90fd\u662f\u80fd\u8fc7\u63d2\u4ef6\u5b9e\u73b0\u7684&#xff0c;\u6bd4\u5982\u53d1\u90ae\u4ef6\u3001\u6bd4\u5982\u4e2d\u6587\u652f\u6301<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># tar -xf jenkins_plugins.tar.gz <\/span><\/p>\n<p><span class=\"token comment\">#\u62f7\u8d1d\u6587\u4ef6\u7684\u65f6\u5019&#xff0c;\u6ce8\u610f\u9009\u9879&#xff0c;-r\u53ef\u4ee5\u62f7\u8d1d\u76ee\u5f55&#xff0c;-p\u4fdd\u7559\u6743\u9650<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cp -rp jenkins_plugins\/* \/var\/lib\/jenkins\/plugins\/<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart jenkins#\u91cd\u542fjenkins\u670d\u52a1<\/span><br \/>\n<span class=\"token comment\">#\u5237\u65b0web\u9875\u9762&#xff0c;\u5982\u679c\u51fa\u73b0\u4e2d\u6587&#xff0c;\u5219\u63d2\u4ef6\u5b89\u88c5\u6210\u529f<\/span><\/p>\n<h3>\u8f6f\u4ef6\u7248\u672c\u7ba1\u7406<\/h3>\n<ul>\n<li>develop\u670d\u52a1\u5668\u64cd\u4f5c<\/li>\n<li>\u53ef\u4ee5\u5728git\u4e2d\u4f7f\u7528tag\u6807\u8bb0\u5c06\u67d0\u4e00\u6b21commit\u63d0\u4ea4\u6807\u8bc6\u4e3a\u67d0\u4e00\u7248\u672c<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;develop ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd myproject\/   #\u8fdb\u5165\u9879\u76ee\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git tag #\u67e5\u770b\u6807\u8bb0&#xff0c;\u9ed8\u8ba4\u6ca1\u6709\u6807\u8bb0<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git tag 1.0 #\u5c06\u5f53\u524d\u63d0\u4ea4&#xff0c;\u6807\u8bc6\u4e3a1.0<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git tag#\u67e5\u770b\u6807\u8bb0<\/span><br \/>\n<span class=\"token number\">1.0<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo &#039;hello world&#039; &gt; index.html<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git add .<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git commit -m &#034;add index.html&#034;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git tag 1.1#\u5c06\u5f53\u524d\u63d0\u4ea4&#xff0c;\u6807\u8bc6\u4e3a1.1<\/span><\/p>\n<p><span class=\"token comment\"># \u5c06\u672c\u5730\u6587\u4ef6\u548ctag\u63a8\u9001\u5230gitlab\u670d\u52a1\u5668<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git push   #\u53ea\u63a8\u9001\u6587\u4ef6&#xff0c;\u4e0d\u63a8\u9001\u6807\u8bb0<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;develop myproject<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># git push &#8211;tags<\/span><\/p>\n<p>\u5728gitlab\u4e0a\u67e5\u770b\u6807\u8bb0<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18hbur0qgha5z.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u914d\u7f6ejenkins\u8bbf\u95eegitlab\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<ul>\n<li>\u65b0\u5efa\u4efb\u52a1<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18lh0q0ucxtf0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18h0kzhrvc0yz.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u53c2\u6570\u5316\u6784\u5efa\u8fc7\u7a0b\u4e2d&#xff0c;&#034;\u540d\u79f0&#034;\u662f\u81ea\u5df1\u5b9a\u4e49\u7684\u53d8\u91cf\u540d&#xff0c;\u7528\u4e8e\u6807\u8bc6tag\u6216\u5206\u652f<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18e2gradfsexp.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18b5xctn2py4x.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>git\u4ed3\u5e93\u5730\u5740&#xff0c;\u5728gitlab\u4e0a\u627e\u5230myproject\u4ed3\u5e93\u7684http\u5730\u5740&#xff0c;\u6ce8\u610f\u5c06gitlab\u540d\u79f0\u6539\u4e3aIP\u5730\u5740<\/p>\n<p><img decoding=\"async\" src=\"2025-04-1834mvcb4zkpt.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6307\u5b9a\u5206\u652f\u6784\u5efa\u7684\u65f6\u5019&#xff0c;\u4f7f\u7528\u4e0a\u9762\u6b65\u9aa4\u521b\u5efa\u7684\u53d8\u91cf<font color=\"red\">$web<\/font><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18wxpgtuq2di4.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-185yg1hqhosxr.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18nobft4epbo4.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u6784\u5efa\u6d4b\u8bd5<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-183kdwvesjc3j.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18l2op0lkbc3h.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5728jenkins\u670d\u52a1\u5668\u67e5\u770b\u5185\u5bb9&#xff0c;\u67e5\u770b\u662f\u5426\u4e0b\u8f7d\u6210\u529f<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls \/var\/lib\/jenkins\/workspace\/myproject\/<\/span><br \/>\nhosts  index.html  README.md  Win.txt<\/p>\n<h3>\u4e0b\u8f7d\u5230\u5b50\u76ee\u5f55<\/h3>\n<ul>\n<li>\u6b64\u65f6\u6709\u4e2a\u95ee\u9898&#xff0c;1.1\u7248\u672c\u7684\u4ee3\u7801\u4f1a\u8986\u76d61.0\u7248\u672c\u7684\u4ee3\u7801&#xff0c;\u65e0\u6cd5\u5b9e\u73b0\u591a\u4e2a\u7248\u672c\u4ee3\u7801\u5e76\u5b58<\/li>\n<li>\u8fd9\u4e2a\u95ee\u9898\u53ef\u4ee5\u4f7f\u7528jenkins\u5b50\u76ee\u5f55\u7684\u65b9\u5f0f\u89e3\u51b3<\/li>\n<li>jenkins\u4e0b\u8f7d\u4e0d\u540c\u7684\u7248\u672c\u5230\u81ea\u5df1\u7684\u5b50\u76ee\u5f55&#xff0c;\u4e0d\u5171\u4eab\u76f8\u540c\u76ee\u5f55<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18kjhengmi3ru.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18hkdgcovc0m3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u65b0\u589e\u65f6&#xff0c;\u5982\u679c\u6ca1\u6709\u4e2d\u6587&#xff0c;\u82f1\u6587\u662f&#034;checkout to a sub directory&#034;<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18jizj2lqpc2v.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18ujzhbj4l4v5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6d4b\u8bd5<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># rm -rf \/var\/lib\/jenkins\/workspace\/myproject\/#\u5220\u9664\u4e4b\u524d\u4e0b\u8f7d\u7684<\/span><\/p>\n<p>\u6267\u884c\u591a\u6b21\u6784\u5efa&#xff0c;\u6784\u5efa\u4e0d\u540c\u7248\u672c<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18n0qdvfgo5zt.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18hcjlojslb1t.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18kasplvsun0u.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18hxgwwgdsj4f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u67e5\u770b\u4e0b\u8f7d\u76ee\u5f55<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls \/var\/lib\/jenkins\/workspace\/myproject\/<\/span><br \/>\nmyproject-1.0 myproject-1.1<\/p>\n<h3>\u90e8\u7f72\u4ee3\u7801\u5230web\u670d\u52a1\u5668<\/h3>\n<h4>\u81ea\u52a8\u5316\u90e8\u7f72\u6d41\u7a0b<\/h4>\n<li>\u7a0b\u5e8f\u5458\u7f16\u5199\u4ee3\u7801&#xff0c;\u63a8\u9001\u5230gitlab\u670d\u52a1\u5668<\/li>\n<li>Jenkins\u670d\u52a1\u5668\u4ecegitlab\u4e0a\u4e0b\u8f7d\u4ee3\u7801<\/li>\n<li>Jenkins\u5904\u7406\u4e0b\u8f7d\u7684\u4ee3\u7801\n<li>\n<ul>\n<li>\u5220\u9664\u4e0b\u8f7d\u76ee\u5f55\u7684\u7248\u672c\u5e93(.git\u672c\u5730\u4ed3\u5e93)<\/li>\n<li>\u5c06\u4e0b\u8f7d\u7684\u4ee3\u7801\u6253\u5305<\/li>\n<li>\u8ba1\u7b97\u7a0b\u5e8f\u538b\u7f29\u5305\u7684md5\u503c<\/li>\n<li>\u5728Jenkins\u4e0a\u5b89\u88c5httpd\u670d\u52a1&#xff0c;\u5171\u4eab\u7a0b\u5e8f\u538b\u7f29\u5305<\/li>\n<\/ul>\n<\/li>\n<\/li>\n<li>web\u670d\u52a1\u5668\u4e0b\u8f7d\u8f6f\u4ef6\u5305&#xff0c;\u5e76\u5e94\u7528&#xff08;\u901a\u8fc7\u811a\u672c\u5b9e\u73b0&#xff09;<\/li>\n<li>\u8bbf\u95ee\u6d4b\u8bd5<\/li>\n<h3>\u914d\u7f6e\u5171\u4eab\u670d\u52a1\u5668<\/h3>\n<ul>\n<li>\u5728jenkins\u4e0a\u5b89\u88c5\u3001\u914d\u7f6ehttpd\u5171\u4eab\u670d\u52a1\u5668<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y install httpd #\u5b89\u88c5apache\u7684\u8f6f\u4ef6\u5305<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir -p \/var\/www\/html\/deploy\/packages #\u521b\u5efajenkins\u4ecegitlab\u4e0a\u4e0b\u8f7d\u7684\u6253\u5305\u4ee3\u7801\u5b58\u653e\u7684\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># chown -R jenkins:jenkins \/var\/www\/html\/deploy\/ #\u4fee\u6539\u6743\u9650&#xff0c;\u56e0\u4e3a\u662fjenkins\u81ea\u52a8\u4e0b\u8f7d\u7684&#xff0c;\u9700\u8981\u4fee\u6539\u5b58\u653e\u7684\u6743\u9650<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl start httpd<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;jenkins ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable httpd<\/span><\/p>\n<h4>\u914d\u7f6ejenkins\u628agitlab\u4e0b\u8f7d\u7684\u4ee3\u7801\u6253\u5305<\/h4>\n<ul>\n<li>\u5728jenkins\u4e0a\u4fee\u6539myproject\u9879\u76ee<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"2025-04-18xa1tzfzkyjg.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18etgqdr0eypv.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18dearkq30wrw.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><span class=\"token assign-left variable\">pkg_dir<\/span><span class=\"token operator\">&#061;<\/span>\/var\/www\/html\/deploy\/packages<br \/>\n<span class=\"token function\">cp<\/span> <span class=\"token parameter variable\">-r<\/span> myproject-<span class=\"token variable\">$web<\/span> <span class=\"token variable\">$pkg_dir<\/span><br \/>\n<span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-rf<\/span> <span class=\"token variable\">$pkg_dir<\/span>\/myproject-<span class=\"token variable\">$web<\/span>\/.git<br \/>\n<span class=\"token builtin class-name\">cd<\/span> <span class=\"token variable\">$pkg_dir<\/span><br \/>\n<span class=\"token function\">tar<\/span> <span class=\"token parameter variable\">-zcf<\/span> myproject-<span class=\"token variable\">$web<\/span>.tar.gz myproject-<span class=\"token variable\">$web<\/span><br \/>\n<span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-rf<\/span> myproject-<span class=\"token variable\">$web<\/span><br \/>\nmd5sum myproject-<span class=\"token variable\">$web<\/span>.tar.gz <span class=\"token operator\">|<\/span> <span class=\"token function\">awk<\/span> <span class=\"token string\">&#039;{print $1}&#039;<\/span> <span class=\"token operator\">&gt;<\/span> myproject-<span class=\"token variable\">$web<\/span>.tar.gz.md5<br \/>\n<span class=\"token builtin class-name\">cd<\/span> <span class=\"token punctuation\">..<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token variable\">$web<\/span> <span class=\"token operator\">&gt;<\/span> ver.txt<\/p>\n<p>\u6d4b\u8bd5\u4fee\u6539\u7684\u4efb\u52a1<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18kjzidk33vnm.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-183u0kwjszkot.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18tmntehayv20.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2025-04-18a5xgwjgsikk.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee&#xff1a;http:\/\/jenkins\u516c\u7f51IP\/deploy\/packages\/\u5373\u53ef\u770b\u5230\u6253\u5305\u7684\u4ee3\u7801<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18pe4a5wbrehl.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>web\u670d\u52a1\u81ea\u52a8\u90e8\u7f72<\/h3>\n<p><span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># dnf -y install httpd  wget <\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir \/var\/www\/download #\u5b58\u50a8jenkins\u4e3b\u673a\u4e0a\u4e0b\u8f7d\u7684\u5e94\u7528\u4ee3\u7801<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir \/var\/www\/deploy #\u90e8\u7f72\u5e94\u7528\u4ee3\u7801<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl start httpd#\u542f\u52a8httpd\u670d\u52a1<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable httpd#\u5c06httpd\u670d\u52a1\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ss -ntulp | grep :80#\u67e5\u770b80\u7aef\u53e3\u662f\u5426\u6b63\u5e38<\/span><\/p>\n<h4>\u7f16\u5199\u81ea\u52a8\u4e0a\u7ebf\u811a\u672c<\/h4>\n<ul>\n<li>\u4e0b\u8f7d\u8f6f\u4ef6\u5305<\/li>\n<li>\u68c0\u67e5\u8f6f\u4ef6\u5305\u662f\u5426\u635f\u574f<\/li>\n<li>\u89e3\u538b\u3001\u90e8\u7f72\u5230web\u670d\u52a1\u5668<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;web1 <span class=\"token operator\">~<\/span><span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># vim web.py<\/span><br \/>\n<span class=\"token keyword\">import<\/span> os<br \/>\n<span class=\"token keyword\">import<\/span> requests<br \/>\n<span class=\"token keyword\">import<\/span> hashlib<br \/>\n<span class=\"token keyword\">import<\/span> tarfile<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">has_new_ver<\/span><span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">,<\/span> ver_url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># web1_ver_path \u4e3a\u5e94\u7528\u670d\u52a1\u5668web1\u4e3b\u673a\u7684\u5f53\u524d\u7248\u672c\u6587\u4ef6\u8def\u5f84<\/span><br \/>\n    <span class=\"token comment\"># \u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728&#xff0c;\u8fd4\u56deTrue, \u63d0\u793a\u6ca1\u6709\u65b0\u7248\u672c<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>exists<span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">True<\/span><br \/>\n    <span class=\"token comment\"># \u5f53web1_ver_path\u5b58\u5728\u65f6&#xff0c;\u5148\u83b7\u53d6\u5f53\u524d\u5e94\u7528\u7684\u7248\u672c\u53f7<\/span><br \/>\n    <span class=\"token keyword\">with<\/span> <span class=\"token builtin\">open<\/span><span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">,<\/span> mode<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;r&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> fr<span class=\"token punctuation\">:<\/span><br \/>\n        local_ver <span class=\"token operator\">&#061;<\/span> fr<span class=\"token punctuation\">.<\/span>read<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u901a\u8fc7requests\u83b7\u53d6jenkins\u670d\u52a1\u5668\u4e0a\u7684\u6700\u65b0\u7248\u672c\u53f7<\/span><br \/>\n    r <span class=\"token operator\">&#061;<\/span> requests<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>ver_url<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u5f53web1\u4e0a\u7684\u7248\u672c\u53f7\u548cJenkins\u670d\u52a1\u5668\u4e0a\u7684\u7248\u672c\u53f7\u4e0d\u76f8\u7b49\u65f6&#xff0c;\u8fd4\u56deTrue, \u5373\u6709\u65b0\u7684\u7248\u672c<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> local_ver <span class=\"token operator\">!&#061;<\/span> r<span class=\"token punctuation\">.<\/span>text<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">True<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">False<\/span><\/p>\n<p><span class=\"token comment\"># \u58f0\u660e\u51fd\u6570file_ok(), \u529f\u80fd&#xff1a;\u5982\u679c\u4e0b\u8f7d\u7684\u5305\u6587\u4ef6\u672a\u635f\u574f&#xff0c;\u5219\u8fd4\u56deTrue&#xff0c;\u5426\u5219\u8fd4\u56deFalse<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">file_ok<\/span><span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">,<\/span> jenkins_tar_md5_url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    m <span class=\"token operator\">&#061;<\/span> hashlib<span class=\"token punctuation\">.<\/span>md5<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">with<\/span> <span class=\"token builtin\">open<\/span><span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">,<\/span> mode<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;rb&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> fw<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">while<\/span> <span class=\"token boolean\">True<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            data <span class=\"token operator\">&#061;<\/span> fw<span class=\"token punctuation\">.<\/span>read<span class=\"token punctuation\">(<\/span><span class=\"token number\">4096<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token builtin\">len<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token keyword\">break<\/span><br \/>\n            m<span class=\"token punctuation\">.<\/span>update<span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># jenkins_tar_md5_url \u4e3ajenkins\u670d\u52a1\u5668\u4e0a\u7684\u538b\u7f29\u5305\u7684md5\u503c\u6587\u4ef6\u94fe\u63a5\u5730\u5740<\/span><br \/>\n    r <span class=\"token operator\">&#061;<\/span> requests<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>jenkins_tar_md5_url<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> m<span class=\"token punctuation\">.<\/span>hexdigest<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> r<span class=\"token punctuation\">.<\/span>text<span class=\"token punctuation\">.<\/span>strip<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u76f8\u7b49&#xff0c;\u4ee3\u8868\u6587\u4ef6\u672a\u635f\u574f&#xff0c;\u8fd4\u56deTrue<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">True<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">False<\/span><\/p>\n<p><span class=\"token comment\"># \u58f0\u660e\u51fd\u6570deploy(), \u529f\u80fd&#xff1a;\u7528\u4e8e\u90e8\u7f72\u8f6f\u4ef6\u5230 web1 \u670d\u52a1\u5668<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">deploy<\/span><span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">,<\/span> web1_deploy_dir<span class=\"token punctuation\">,<\/span> dest<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    tar <span class=\"token operator\">&#061;<\/span> tarfile<span class=\"token punctuation\">.<\/span><span class=\"token builtin\">open<\/span><span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u6253\u5f00\u538b\u7f29\u5305web1_tar_path<\/span><br \/>\n    tar<span class=\"token punctuation\">.<\/span>extractall<span class=\"token punctuation\">(<\/span>path<span class=\"token operator\">&#061;<\/span>web1_deploy_dir<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u89e3\u538b\u5230web1_deploy_dir\u76ee\u5f55\u4e0b<\/span><br \/>\n    tar<span class=\"token punctuation\">.<\/span>close<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u5173\u95edtar<\/span><br \/>\n    <span class=\"token comment\"># \u83b7\u53d6web1_tar_path\u53d8\u91cf\u4e2d&#xff0c;\u6700\u540e\u4e00\u4e2a&#039;\/&#039;&#xff0c;\u53f3\u8fb9\u7684\u5185\u5bb9&#xff0c;\u7136\u540e\u505a\u5207\u7247&#xff0c;\u53bb\u9664&#034;.tar.gz&#034;&#xff0c;\u53ea\u7559\u4e0b\u6587\u4ef6\u540d<\/span><br \/>\n    file_name <span class=\"token operator\">&#061;<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>basename<span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">:<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">7<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token comment\"># \u5c06\u53d8\u91cfweb1_deploy_dir\u548c\u53d8\u91cffile_name\u62fc\u63a5\u5728\u4e00\u8d77<\/span><br \/>\n    app_dir <span class=\"token operator\">&#061;<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>join<span class=\"token punctuation\">(<\/span>web1_deploy_dir<span class=\"token punctuation\">,<\/span> file_name<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u521b\u5efa\u94fe\u63a5&#xff0c;\u5982\u679c\u8f6f\u94fe\u63a5dest\u5b58\u5728&#xff0c;\u5220\u9664\u8f6f\u8fde\u63a5&#xff0c;\u7136\u540e\u4e3aapp_dir\u521b\u5efa\u65b0\u7684\u8f6f\u94fe\u63a5<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>exists<span class=\"token punctuation\">(<\/span>dest<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        os<span class=\"token punctuation\">.<\/span>remove<span class=\"token punctuation\">(<\/span>dest<span class=\"token punctuation\">)<\/span><br \/>\n    os<span class=\"token punctuation\">.<\/span>symlink<span class=\"token punctuation\">(<\/span>app_dir<span class=\"token punctuation\">,<\/span> dest<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> __name__ <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token string\">&#034;__main__&#034;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\">### \u5224\u65adjenkins\u670d\u52a1\u5668\u4e0a\u662f\u5426\u6709\u65b0\u7248\u672c<\/span><br \/>\n    <span class=\"token comment\"># ver_url \u4e3ajenkins\u670d\u52a1\u5668\u7684\u5f53\u524d\u7248\u672c\u6587\u4ef6\u8def\u5f84<\/span><br \/>\n    <span class=\"token comment\"># web1_ver_path \u4e3a\u5e94\u7528\u670d\u52a1\u5668web1\u4e3b\u673a\u7684\u5f53\u524d\u7248\u672c\u6587\u4ef6\u8def\u5f84<\/span><br \/>\n    <span class=\"token comment\"># \u8fd9\u91cc\u7684\u5730\u5740\u9700\u8981\u6c42\u6539\u4e3a\u81ea\u5df1\u7684IP\u5730\u5740<\/span><br \/>\n    ver_url <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;http:\/\/120.46.84.196\/deploy\/ver.txt&#034;<\/span><br \/>\n    web1_ver_path <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;\/var\/www\/deploy\/ver.txt&#034;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> has_new_ver<span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">,<\/span> ver_url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;no new version~&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        exit<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n    <span class=\"token comment\"># \u5982\u679c\u670d\u52a1\u5668\u4e0a\u6709\u65b0\u7248\u672c&#xff0c;\u5219\u4e0b\u8f7d\u65b0\u7248\u672c<\/span><br \/>\n    <span class=\"token comment\"># r.text \u4e3ajenkins\u670d\u52a1\u5668\u7684\u5f53\u524d\u7248\u672c\u5185\u5bb9<\/span><br \/>\n    <span class=\"token comment\"># jenkins_tar_url \u4e3ajenkins\u670d\u52a1\u5668\u4e0a\u7684\u538b\u7f29\u5305\u94fe\u63a5\u5730\u5740<\/span><br \/>\n    <span class=\"token comment\"># web1_tar_path \u4e3a\u5e94\u7528\u670d\u52a1\u5668web1\u4e3b\u673a\u7684\u538b\u7f29\u5305\u8def\u5f84<\/span><br \/>\n    <span class=\"token comment\"># \u8fd9\u91cc\u7684\u5730\u5740\u9700\u8981\u4fee\u6539\u4e3a\u81ea\u5df1\u7684IP\u5730\u5740<\/span><br \/>\n    r <span class=\"token operator\">&#061;<\/span> requests<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>ver_url<span class=\"token punctuation\">)<\/span><br \/>\n    jenkins_tar_url <span class=\"token operator\">&#061;<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;http:\/\/120.46.84.196\/deploy\/packages\/myproject-<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>r<span class=\"token punctuation\">.<\/span>text<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">.tar.gz&#034;<\/span><\/span><br \/>\n    web1_tar_path <span class=\"token operator\">&#061;<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\/var\/www\/download\/myproject-<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>r<span class=\"token punctuation\">.<\/span>text<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">.tar.gz&#034;<\/span><\/span><br \/>\n    <span class=\"token keyword\">with<\/span> <span class=\"token builtin\">open<\/span><span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">,<\/span> mode<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;wb&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> fw<span class=\"token punctuation\">:<\/span><br \/>\n        fw<span class=\"token punctuation\">.<\/span>write<span class=\"token punctuation\">(<\/span>requests<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>jenkins_tar_url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u6821\u9a8c\u4e0b\u8f7d\u7684\u8f6f\u4ef6\u5305\u662f\u5426\u635f\u574f&#xff0c;\u5982\u679c\u635f\u574f\u5219\u5220\u9664 os.remove()<\/span><br \/>\n    <span class=\"token comment\"># jenkins_tar_md5_url \u4e3ajenkins\u670d\u52a1\u5668\u4e0a\u7684\u538b\u7f29\u5305\u7684md5\u503c\u6587\u4ef6\u94fe\u63a5\u5730\u5740<\/span><br \/>\n    jenkins_tar_md5_url <span class=\"token operator\">&#061;<\/span> jenkins_tar_url <span class=\"token operator\">&#043;<\/span> <span class=\"token string\">&#034;.md5&#034;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> file_ok<span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">,<\/span> jenkins_tar_md5_url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;File has been broken~&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        os<span class=\"token punctuation\">.<\/span>remove<span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">)<\/span><br \/>\n        exit<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n    web1_deploy_dir <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\/var\/www\/deploy&#039;<\/span><br \/>\n    dest <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\/var\/www\/html\/current&#039;<\/span><br \/>\n    deploy<span class=\"token punctuation\">(<\/span>web1_tar_path<span class=\"token punctuation\">,<\/span> web1_deploy_dir<span class=\"token punctuation\">,<\/span> dest<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># \u66f4\u65b0\u672c\u5730\u7684\u7248\u672c\u6587\u4ef6<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>exists<span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        os<span class=\"token punctuation\">.<\/span>remove<span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">with<\/span> <span class=\"token builtin\">open<\/span><span class=\"token punctuation\">(<\/span>web1_ver_path<span class=\"token punctuation\">,<\/span> mode<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;w&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> fw<span class=\"token punctuation\">:<\/span><br \/>\n        fw<span class=\"token punctuation\">.<\/span>write<span class=\"token punctuation\">(<\/span>requests<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>ver_url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>text<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;web1 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># python3 web.py<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web1 html<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ls \/var\/www\/deploy<\/span><br \/>\nmyproject-1.1  ver.txt<\/p>\n<p>\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/web\u670d\u52a1\u5668\u516c\u7f51IP\/current \u53ef\u4ee5\u770b\u5230\u90e8\u7f72\u7684\u6587\u4ef6\u9875\u9762<\/p>\n<p><img decoding=\"async\" src=\"2025-04-18adrreakewu1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.5k\u6b21\uff0c\u70b9\u8d5e40\u6b21\uff0c\u6536\u85cf33\u6b21\u3002CI\uff1a\u6301\u7eed\u96c6\u6210\uff08Continuous Integration\uff09CD\uff1a\u6301\u7eed\u4ea4\u4ed8\uff08Continuous Delivery\/Deployment\uff09_\u670d\u52a1\u5668\u90e8\u7f72gitlab<\/p>\n","protected":false},"author":2,"featured_media":15588,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[273,99,43,44],"topic":[],"class_list":["post-15608","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-gitlab","tag-java","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u90e8\u7f72GitLab\u670d\u52a1\u5668 - \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\/15608.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u90e8\u7f72GitLab\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.5k\u6b21\uff0c\u70b9\u8d5e40\u6b21\uff0c\u6536\u85cf33\u6b21\u3002CI\uff1a\u6301\u7eed\u96c6\u6210\uff08Continuous Integration\uff09CD\uff1a\u6301\u7eed\u4ea4\u4ed8\uff08Continuous Delivery\/Deployment\uff09_\u670d\u52a1\u5668\u90e8\u7f72gitlab\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/15608.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-18T14:08:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140758-68025cbe2265d.png\" \/>\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=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/15608.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/15608.html\",\"name\":\"\u90e8\u7f72GitLab\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T14:08:07+00:00\",\"dateModified\":\"2025-04-18T14:08:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/15608.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/15608.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/15608.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u90e8\u7f72GitLab\u670d\u52a1\u5668\"}]},{\"@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":"\u90e8\u7f72GitLab\u670d\u52a1\u5668 - \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\/15608.html","og_locale":"zh_CN","og_type":"article","og_title":"\u90e8\u7f72GitLab\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.5k\u6b21\uff0c\u70b9\u8d5e40\u6b21\uff0c\u6536\u85cf33\u6b21\u3002CI\uff1a\u6301\u7eed\u96c6\u6210\uff08Continuous Integration\uff09CD\uff1a\u6301\u7eed\u4ea4\u4ed8\uff08Continuous Delivery\/Deployment\uff09_\u670d\u52a1\u5668\u90e8\u7f72gitlab","og_url":"https:\/\/www.wsisp.com\/helps\/15608.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T14:08:07+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140758-68025cbe2265d.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/15608.html","url":"https:\/\/www.wsisp.com\/helps\/15608.html","name":"\u90e8\u7f72GitLab\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T14:08:07+00:00","dateModified":"2025-04-18T14:08:07+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/15608.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/15608.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/15608.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u90e8\u7f72GitLab\u670d\u52a1\u5668"}]},{"@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\/15608","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=15608"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/15608\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/15588"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=15608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=15608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=15608"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=15608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}