{"id":204376,"date":"2020-11-13T10:59:41","date_gmt":"2020-11-13T02:59:41","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=204376"},"modified":"2020-11-02T10:13:38","modified_gmt":"2020-11-02T02:13:38","slug":"jenkins-configuration","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/jenkins-configuration.html","title":{"rendered":"Jenkins\u914d\u7f6e\u90a3\u4e9b\u4e8b\u6765\u8fd9\u91cc\u8be6\u7ec6\u804a\u804a"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u5c31\u7ed3\u5408\u4f5c\u8005\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u6765\u8bf4\u8bf4 Jenkins \u7684\u90a3\u4e9b\u8be6\u7ec6\u914d\u7f6e\uff0c\u8fd9\u4e9b\u914d\u7f6e\u4e3b\u8981\u5c31\u662f\u5f53\u6211\u4eec\u8ba9 Jenkins \u5e2e\u6211\u4eec\u90e8\u7f72\u5b8c\u6210\u4e4b\u540e\uff0c\u9700\u8981\u6267\u884c\u7684\u811a\u672c<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u8fd9\u7bc7\u6587\u7ae0\u5c31\u7ed3\u5408\u4f5c\u8005\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u6765\u8bf4\u8bf4 Jenkins \u7684\u90a3\u4e9b\u8be6\u7ec6\u914d\u7f6e\uff0c\u8fd9\u4e9b\u914d\u7f6e\u4e3b\u8981\u5c31\u662f\u5f53\u6211\u4eec\u8ba9 Jenkins \u5e2e\u6211\u4eec\u90e8\u7f72\u5b8c\u6210\u4e4b\u540e\uff0c\u9700\u8981\u6267\u884c\u7684\u811a\u672c
\n\"\"
\n\u5148\u8bf4\u4e00\u4e0b\uff0c\u8fd9\u4e9b\u914d\u7f6e\u53ea\u662f\u8d77\u53c2\u8003\u4ef7\u503c\uff0c\u5177\u4f53\u8fd8\u662f\u9700\u8981\u6839\u636e\u81ea\u5df1\u7684\u60c5\u51b5\u6765\u5466~<\/p>\n

\u5bf9\u4e8e\u540e\u7aef\u6765\u8bf4\uff0c\u914d\u7f6e\u6587\u4ef6\u4e3b\u8981\u5728\u6784\u5efa\u4e4b\u540e\u9700\u8981\u6267\u884c\u7684\u64cd\u4f5c( # \u540e\u9762\u4e3a\u6ce8\u91ca\u5185\u5bb9)<\/p>\n

\r\n#!\/bin\/sh \r\ntomcat_path=\/usr\/local\/tomcats\/tomcat-test        #\u5b9a\u4e49 tomcat \u7684\u4f4d\u7f6e \r\nproject_web=$tomcat_path\/test.war      #\u5b9a\u4e49\u9879\u76ee\u6253\u5305\u4f4d\u7f6e \r\nif [ -f $project_web ] ;then  \r\n echo -- stop tomcat \r\n #kill tomcat pid \r\n pidlist=`ps -ef | grep tomcat-test | grep -v grep | awk '{print $2}'`   #\u67e5\u770b\u662f\u5426\u6709\u8fdb\u7a0b\u6b63\u5728\u8fd0\u884c \r\n if [ \"$pidlist\" = \"\" ]        #\u6ca1\u6709\u8fdb\u7a0b\u5728\u8fd0\u884c,\u5219\u63d0\u793a \r\n  then \r\n   echo \"no tomcat pid alive!\" \r\n else             #\u6709\u8fdb\u7a0b\u5728\u8fd0\u884c,\u6740\u6389 \r\n    echo \"tomcat Id list :$pidlist\" \r\n    kill -9 $pidlist \r\n    echo \"KILL $pidlist:\" \r\n    echo \"tomcat stop success\" \r\n fi  \r\n  \r\n    echo -- \u6b63\u5728\u90e8\u7f72$project_web         #\u5c06\u8fdb\u7a0b\u6740\u6389\u4e4b\u540e,\u91cd\u65b0\u8fdb\u884c\u90e8\u7f72 \r\n    if [ -f $tomcat_path\/webapps\/test.war ] ;then   #\u67e5\u770b \/webapps \u76ee\u5f55\u4e0b\u662f\u5426\u6709\u4ee5\u524d\u7684 war \u5305,\u5982\u679c\u6709,\u5220\u6389 \r\n        rm -f $tomcat_path\/webapps\/test.war \r\n        rm -rf $tomcat_path\/webapps\/test \r\n        echo -- \u6b63\u5728\u5220\u9664$project_web \r\n    fi  \r\n        cp $project_web $tomcat_path\/webapps\/test.war #\u5c06\u65b0\u751f\u6210\u7684 war \u5305\u590d\u5236\u5230 \/webapps \u76ee\u5f55\u4e0b \r\n    # start tomcat \r\n    echo $tomcat_path \r\n    #sleep 5 \r\n    export JAVA_HOME=\/usr\/java\/latest \r\n    #$tomcat_path\/bin\/startup.sh \r\n    ${tomcat_path}\/bin\/startup.sh  \r\nelse  \r\necho $BUILD_ID - \u672a\u627e\u5230$project_web \r\nfi \r\n<\/pre>\n

\u5bf9\u4e8e\u524d\u7aef\u6765\u8bf4\uff0c\u4e3b\u8981\u5c31\u662f\u9700\u8981\u6ce8\u610f\u4e00\u4e0b\u524d\u7aef\u7279\u6709\u7684\u6253\u5305\u65b9\u5f0f\uff1a<\/p>\n

\r\nnpm install --unsafe-perm \r\nng build --prod --env=test --output-path=typing-dev --base-href .\/ \r\n<\/pre>\n

\u5bf9\u4e8e k8s \u6765\u8bf4\uff0c\u9700\u8981\u5728\u6784\u5efa\u65f6\u521b\u5efa\u4e8b\u4ef6\uff1a<\/p>\n

\r\n#!\/bin\/sh -l  \r\n \r\nexamimage_path=reg.afen.com\/library\/test:1.0.0    #\u5b9a\u4e49\u955c\u50cf\u5728 harbor \u4e0a\u7684\u4f4d\u7f6e \r\n \r\ncp test-web\/target\/test-web.war test-web\/src\/profiles\/k8s_prod\/test-web.war  #\u5c06 war \u590d\u5236\u5230\u76ee\u6807\u76ee\u5f55\u4e0b \r\ncd test-web\/src\/profiles\/k8s_prod   #\u8fdb\u5165\u76ee\u6807\u76ee\u5f55 \r\ndocker build -t $examimage_path .   #\u5f00\u59cb\u521b\u5efa\u65b0\u7684\u955c\u50cf,\u6ce8\u610f\u540e\u9762\u8fd8\u6709\u4e00\u4e2a\".\",\u8981\u4e0d\u7136\u547d\u4ee4\u662f\u4e0d\u4f1a\u751f\u6548\u7684 \r\ndocker push $examimage_path    #\u5c06\u6784\u5efa\u597d\u7684\u955c\u50cf\u63a8\u5230 harbor \u4e0a\u9762\u53bb \r\necho '\u63a8\u9001\u955c\u50cf\u5230harbor' \r\n \r\n#\u5220\u9664\u672c\u5730\u955c\u50cf \r\ndocker rmi -f $examimage_path   #\u63a8\u9001\u6210\u529f\u4e4b\u540e,\u5c06\u672c\u5730\u955c\u50cf\u5220\u9664 \r\n \r\n#k8s\u90e8\u7f72 \r\necho '\u5f00\u59cb\u90e8\u7f72' \r\nkubectl delete -f $WORKSPACE\/test-web\/src\/profiles\/k8s_prod\/.   #\u5c06\u672c\u5730\u7684\u90fd\u5220\u9664 \r\n \r\n \r\necho $WORKSPACE \r\nkubectl create -f $WORKSPACE\/test-web\/src\/profiles\/k8s_prod\/.  #\u90e8\u7f72\u6700\u65b0\u7684 \r\n<\/pre>\n

\u5230\u8fd9\u91cc\uff0c\u8981\u5206\u4eab\u7684\u5185\u5bb9\u5c31\u7ed3\u675f\u5566~<\/p>\n

\u5728\u9879\u76ee\u4e2d\u4f60\u662f\u5982\u4f55\u4f7f\u7528 Jenkins \u7684\u5462?<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8fd9\u7bc7\u6587\u7ae0\u5c31\u7ed3\u5408\u4f5c\u8005\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u6765\u8bf4\u8bf4 Jenkins \u7684\u90a3\u4e9b\u8be6\u7ec6\u914d\u7f6e\uff0c\u8fd9\u4e9b\u914d\u7f6e\u4e3b\u8981\u5c31\u662f\u5f53\u6211\u4eec\u8ba9 Jenkins […]<\/p>\n","protected":false},"author":1898,"featured_media":204379,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[612],"class_list":["post-204376","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread","tag-jenkins"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=204376"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204376\/revisions"}],"predecessor-version":[{"id":204380,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204376\/revisions\/204380"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/204379"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=204376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=204376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=204376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}