{"id":1473,"date":"2023-03-24T22:30:16","date_gmt":"2023-03-24T14:30:16","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1473"},"modified":"2023-04-28T20:33:50","modified_gmt":"2023-04-28T12:33:50","slug":"jenkins-deploys-java-project-configuration","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/24\/jenkins-deploys-java-project-configuration\/","title":{"rendered":"Jenkins\u90e8\u7f72Java\u9879\u76ee\u914d\u7f6e"},"content":{"rendered":"<h2>\u63d2\u4ef6<\/h2>\n<p>\u63d2\u4ef6: <code>Publish Over SSH<\/code><br \/>\n\u63d2\u4ef6: <code>Maven Integration<\/code><\/p>\n<p><!-- more --><\/p>\n<h2>\u521b\u5efa\u4efb\u52a1<\/h2>\n<h3>\u7c7b\u578b<\/h3>\n<p>\u9009\u62e9<code>\u6784\u5efa\u4e00\u4e2aMaven\u9879\u76ee<\/code><\/p>\n<h3>\u51ed\u636e<\/h3>\n<p>\u6dfb\u52a0\u51ed\u636e -&gt; Jenkins<\/p>\n<p>Domain: <code>\u5168\u5c40\u51ed\u636e<\/code><br \/>\n\u7c7b\u578b: <code>Username with password<\/code><\/p>\n<h3>Pre Steps (\u53ef\u9009)<\/h3>\n<p>\u9009\u62e9<code>\u6267\u884c Shell<\/code><\/p>\n<pre><code>cd \/root\/.m2\/repository\/com\/lianlian\/global\/pay\nrm -rf *<\/code><\/pre>\n<h3>Build<\/h3>\n<p>Root POM: <code>appblog-registry\/pom.xml<\/code><br \/>\nGoals and options: <code>clean package -DskipTests -U<\/code><\/p>\n<h3>Post Steps<\/h3>\n<p>\u9009\u62e9<code>Send files or execute commands over SSH<\/code>\u6216<code>Send build artifacts over SSH<\/code><\/p>\n<p>\u52fe\u9009<code>Run regardless of build result<\/code><\/p>\n<p>Name: \u9009\u62e9SSH\u53d1\u5e03\u914d\u7f6e\u7684\u670d\u52a1\u5668<br \/>\nSource files: <code>**\/*.jar<\/code><br \/>\nRemove prefix: <code>appblog-registry\/target<\/code><br \/>\nExec command: <\/p>\n<pre><code>project=appblog-registry\njar_name=`ls . | grep &quot;$project&quot;`\npid=`ps -ef | grep &quot;$jar_name&quot; | grep java | awk &#039;{print $2}&#039;`\nif [ $pid ]; then\n   kill -9 $pid\nfi\nnohup \/usr\/local\/java\/jdk1.8.0_231\/bin\/java -jar -Dspring.profiles.active=prod $jar_name &gt;\/dev\/null 2&gt;&amp;1 &amp;<\/code><\/pre>\n<blockquote>\n<p>\u6ce8\uff1ajava\u52a1\u5fc5\u4f7f\u7528\u5168\u8def\u5f84\uff0c\u5426\u5219\u767b\u5f55SSH\u670d\u52a1\u5668\u7684\u975eroot\u7528\u6237\u5bb9\u6613\u5bfc\u81f4\u547d\u4ee4\u627e\u4e0d\u5230<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u63d2\u4ef6 \u63d2\u4ef6: Publish Over SSH \u63d2\u4ef6: Maven Integration \u521b\u5efa\u4efb\u52a1 \u7c7b\u578b \u9009 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[229],"tags":[],"class_list":["post-1473","post","type-post","status-publish","format-standard","hentry","category-jenkins"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1473"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1473\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}