{"id":124969,"date":"2018-10-31T09:14:36","date_gmt":"2018-10-31T01:14:36","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=124969"},"modified":"2018-10-22T10:41:47","modified_gmt":"2018-10-22T02:41:47","slug":"tomcat-deploys-jenkins","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/tomcat-deploys-jenkins.html","title":{"rendered":"tomcat\u642d\u5efa\u4e4bJenkins\u73af\u5883"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nJenkins\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java Web\u9879\u76ee\uff0c\u4e00\u4e2a\u6301\u7eed\u96c6\u6210\u7684Web\u9879\u76ee\u3002\u4f8b\u5982\u5728\u81ea\u52a8\u5316\u6d4b\u8bd5\u4e2d\uff0c\u5f00\u53d1\u4e86\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u811a\u672c\uff0c\u4e0d\u53ef\u80fd\u4e00\u76f4\u7528IDE\u6765\u8fd0\u884c\uff0c\u7136\u540e\u67e5\u770b\u6d4b\u8bd5\u7ed3\u679c\uff0c\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u5c31\u9700\u8981\u501f\u52a9\u4e00\u4e2a\u5e73\u53f0\uff0c\u53ef\u4ee5\u81ea\u52a8\u83b7\u53d6\u6700\u65b0\u4ee3\u7801\uff0c\u7f16\u8bd1\u5e76\u6784\u5efa\uff0c\u5e76\u4e14\u662f\u5728\u8bbe\u7f6e\u7684\u65f6\u95f4\u6301\u7eed\u6267\u884c\uff0c\u81ea\u52a8\u5316\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\u4ee5\u540e\u5e76\u628a\u6d4b\u8bd5\u7684\u7ed3\u679c\u4ee5\u90ae\u4ef6\u7684\u5f62\u5f0f\u53d1\u9001\u7ed9\u6307\u5b9a\u7684\u5f00\u53d1\uff0c\u6d4b\u8bd5\u4eba\u5458\uff0c\u8fd9\u662fJenkins\u5728\u81ea\u52a8\u5316\u6d4b\u8bd5\u4e0a\u7684\u4e3b\u8981\u7528\u9014\u3002 <\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5b89\u88c5tomcat\u90e8\u7f72Jenkins\u73af\u5883<\/strong><\/div>\n

1.\u4ece\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684tomcat
\n\u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/tomcat.apache.org\/
\n2.Jenkins \u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672cwar\u5305
\nJenkins\u5b98\u7f51\u5730\u5740\uff1ahttp:\/\/jenkins-ci.org\/
\n3.\u5b89\u88c5Jenkins<\/p>\n

\u6b65\u9aa4\u4e00<\/strong><\/span><\/div>\n

\u5c06jenkins\u7684war\u5305\u62f7\u8d1d\u5230 $TOMCAT_HOME\/webapps \u4e0b\uff08\u4e0d\u7528\u89e3\u538b\uff09\uff0c\u5220\u9664 webapps \u4e0b\u5176\u4ed6\u76ee\u5f55<\/p>\n

\u6b65\u9aa4\u4e8c<\/strong><\/span><\/div>\n

\u521b\u5efa\u5b58\u653ejenkins\u6570\u636e\u7684\u76ee\u5f55\uff0c\u5e76\u6dfb\u52a0\u73af\u5883\u53d8\u91cf\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

\r\nmkdir \/jenkins\r\nvi \/etc\/profile \u6dfb\u52a0 export JENKINS_HOME=\/jenkins\r\n<\/pre>\n
\u6b65\u9aa4\u4e09<\/strong><\/span><\/div>\n

\u5199\u542f\u52a8jenkins\u670d\u52a1\u811a\u672c\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

\r\n#!\/bin\/sh\r\n#\r\n# Startup script for the Jenkins Continuous Integration server\r\n# (via Jakarta Tomcat Java Servlets and JSP server)\r\n#\r\n# chkconfig: - 85 15\r\n# description: Jakarta Tomcat Java Servlets and JSP server\r\n# processname: tomcat\r\n# pidfile: \/var\/run\/tomcat.pid\r\n# Set Tomcat environment.\r\nJENKINS_USER=root\r\nLOCKFILE=\/var\/lock\/jenkins\r\nexport PATH=\/usr\/local\/bin:$PATH\r\nexport HOME=\/jenkins\r\nexport JAVA_HOME=\/opt\/jdk1.8.0_161\r\nexport JENKINS_BASEDIR=\/jenkins\r\nexport TOMCAT_HOME=\/opt\/apache-tomcat-9.0.8\r\nexport CATALINA_PID=$JENKINS_BASEDIR\/jenkins-tomcat.pid\r\nexport CATALINA_OPTS=\"-DJENKINS_HOME=$JENKINS_BASEDIR\/jenkins-home -Xmx512m -Djava.awt.headless=true\"\r\n \r\n[ -f $TOMCAT_HOME\/bin\/catalina.sh ] || exit 0\r\n \r\nexport PATH=$PATH:\/usr\/bin:\/usr\/local\/bin\r\n \r\n# See how we were called.\r\ncase \"$1\" in\r\nstart)\r\n# Start daemon.\r\necho -n \"Starting Tomcat: \"\r\nsu -p -s \/bin\/sh $JENKINS_USER -c \"$TOMCAT_HOME\/bin\/catalina.sh start\"\r\nRETVAL=$?\r\necho\r\n[ $RETVAL = 0 ] && touch $LOCKFILE\r\n;;\r\nstop)\r\n# Stop daemons.\r\necho -n \"Shutting down Tomcat: \"\r\nsu -p -s \/bin\/sh $JENKINS_USER -c \"$TOMCAT_HOME\/bin\/catalina.sh stop\"\r\nRETVAL=$?\r\necho\r\n[ $RETVAL = 0 ] && rm -f $LOCKFILE\r\n;;\r\nrestart)\r\n$0 stop\r\n$0 start\r\n;;\r\ncondrestart)\r\n[ -e $LOCKFILE ] && $0 restart\r\n;;\r\nstatus)\r\nstatus tomcat\r\n;;\r\n*)\r\necho \"Usage: $0 {start|stop|restart|status}\"\r\nexit 1\r\nesac\r\n \r\nexit 0\r\n<\/pre>\n
\u6b65\u9aa4\u56db<\/strong><\/span><\/div>\n

\u8d4b\u4e88\u542f\u52a8\u811a\u672c\u53ef\u6267\u884c\u6743\u9650\uff0c\u5e76\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

\r\nchmod a+x \/etc\/init.d\/jenkins\r\nchkconfig jenkins on\r\nservice jenkins start\r\n<\/pre>\n
\u6b65\u9aa4\u4e94<\/strong><\/span><\/div>\n

http:\/\/192.168.1.171:8080\/jenkins\/ \u53ef\u4ee5\u770b\u5230 Jenkins \u5df2\u7ecf\u542f\u52a8\u4e86<\/p>\n

\u5e03\u7f6e Nginx\u4e4b\u53cd\u5411\u4ee3\u7406<\/strong><\/div>\n

\u4e0b\u8f7d\u5e76\u5b89\u88c5nginx\uff0c\u4e0b\u8f7d\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u7f16\u8f91nginx\u542f\u52a8\u6587\u4ef6\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

\r\nvi \/etc\/nginx\/nginx.conf\r\n\u4fee\u6539\u6210\u5982\u4e0b\u5185\u5bb9\r\nuser root;\r\nworker_processes auto;\r\nerror_log \/var\/log\/nginx\/error.log error;\r\n \r\nevents {\r\n    worker_connections 10240;\r\n}\r\n \r\nhttp{\r\n    server {\r\n        listen       80;\r\n        server_name  ci.abc.com;\r\n        client_max_body_size 60M;\r\n        client_body_buffer_size 512k;\r\n        location \/ {\r\n            proxy_pass      http:\/\/localhost:8080;\r\n            proxy_redirect  off;\r\n            proxy_set_header Host $host;\r\n            proxy_set_header X-Real-IP $remote_addr;\r\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n

\u542f\u52a8nginx service nginx start
\n\u7136\u540e\u4fee\u6539\u672c\u673ahosts\u6587\u4ef6\uff08C:\\Windows\\System32\\drivers\\etc\\hosts\uff09
\n192.168.1.171 ci.abc.com
\n\u6700\u540e\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165 http:\/\/ci.abc.com\/jenkins \u53ef\u4ee5\u770b\u5230\u9875\u9762\u4e86\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

1.\u4ece\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684tomcat \u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/tomcat.apache.org\/ 2.Je […]<\/p>\n","protected":false},"author":1329,"featured_media":124986,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-124969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/124969","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\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=124969"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/124969\/revisions"}],"predecessor-version":[{"id":124989,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/124969\/revisions\/124989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/124986"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=124969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=124969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=124969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}