3
回答
jenkins如何自动部署项目
极速云服务器,低至1.04元/天>>>   

我现在有一个项目,项目结构类似tomcat

有bin,logs, conf,等目录

bin目录下有一个start.sh , stop.sh 脚本,分别为启动脚本,关闭脚本

请问,如何在jenkins里面自动构建,并且运行这个项目

也就是说,先编译,然后把编译后的zip包scp到远程测试机,然后unzip后,执行start.sh(要先把原来的stop掉)

举报
共有3个答案 最后回答: 1年前
Started by user anonymous Building in workspace /root/.jenkins/jobs/webapp-test/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://git.oschina.net/253498229/webapp-test.git # timeout=10
Fetching upstream changes from https://git.oschina.net/253498229/webapp-test.git > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://git.oschina.net/253498229/webapp-test.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision bc9ab274b6c56d9a932bde9146834a4803fbf782 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f bc9ab274b6c56d9a932bde9146834a4803fbf782
 > git rev-list 2a017200b9740d4cc554b9338f1506e0128e7bce # timeout=10
Parsing POMs
[workspace] $ /usr/lib/jvm/java-7-openjdk-i386/bin/java -cp /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.5.jar:/root/apache-maven-3.3.9/boot/plexus-classworlds-2.5.2.jar:/root/apache-maven-3.3.9/conf/logging jenkins.maven3.agent.Maven31Main /root/apache-maven-3.3.9 /root/apache-tomcat-7.0.70/webapps/jenkins/WEB-INF/lib/remoting-2.59.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.5.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.5.jar 59374
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f /root/.jenkins/jobs/webapp-test/workspace/pom.xml clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] webapp-test
[INFO] core
[INFO] web Maven Webapp
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building webapp-test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ webapp-test --- [INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ webapp-test --- [INFO] Installing /root/.jenkins/jobs/webapp-test/workspace/pom.xml to /root/.m2/repository/cn/codeforfun/webapp-test/1.0-SNAPSHOT/webapp-test-1.0-SNAPSHOT.pom
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ core --- [INFO] Deleting /root/.jenkins/jobs/webapp-test/workspace/core/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ core --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /root/.jenkins/jobs/webapp-test/workspace/core/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ core --- [INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ core --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /root/.jenkins/jobs/webapp-test/workspace/core/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ core --- [INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ core --- [INFO] No tests to run.
[JENKINS] Recording test results
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ core --- [WARNING] JAR will be empty - no content was marked for inclusion! [INFO] Building jar: /root/.jenkins/jobs/webapp-test/workspace/core/target/core-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ core --- [INFO] Installing /root/.jenkins/jobs/webapp-test/workspace/core/target/core-1.0-SNAPSHOT.jar to /root/.m2/repository/cn/codeforfun/core/1.0-SNAPSHOT/core-1.0-SNAPSHOT.jar
[INFO] Installing /root/.jenkins/jobs/webapp-test/workspace/core/pom.xml to /root/.m2/repository/cn/codeforfun/core/1.0-SNAPSHOT/core-1.0-SNAPSHOT.pom
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building web Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ web --- [INFO] Deleting /root/.jenkins/jobs/webapp-test/workspace/web/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ web --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ web --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 2 source files to /root/.jenkins/jobs/webapp-test/workspace/web/target/classes [WARNING] /root/.jenkins/jobs/webapp-test/workspace/web/src/main/java/cn/codeforfun/common/CommonConfig.java: /root/.jenkins/jobs/webapp-test/workspace/web/src/main/java/cn/codeforfun/common/CommonConfig.java uses or overrides a deprecated API. [WARNING] /root/.jenkins/jobs/webapp-test/workspace/web/src/main/java/cn/codeforfun/common/CommonConfig.java: Recompile with -Xlint:deprecation for details. [INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ web --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /root/.jenkins/jobs/webapp-test/workspace/web/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ web --- [INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ web --- [INFO] No tests to run.
[JENKINS] Recording test results
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ web --- [INFO] Packaging webapp
[INFO] Assembling webapp [web] in [/root/.jenkins/jobs/webapp-test/workspace/web/target/web]
[INFO] Processing war project
[INFO] Copying webapp resources [/root/.jenkins/jobs/webapp-test/workspace/web/src/main/webapp]
[INFO] Webapp assembled in [50 msecs]
[INFO] Building war: /root/.jenkins/jobs/webapp-test/workspace/web/target/web.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ web --- [INFO] Installing /root/.jenkins/jobs/webapp-test/workspace/web/target/web.war to /root/.m2/repository/cn/codeforfun/web/1.0-SNAPSHOT/web-1.0-SNAPSHOT.war
[INFO] Installing /root/.jenkins/jobs/webapp-test/workspace/web/pom.xml to /root/.m2/repository/cn/codeforfun/web/1.0-SNAPSHOT/web-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] webapp-test ........................................ SUCCESS [  0.678 s]
[INFO] core ............................................... SUCCESS [  1.230 s]
[INFO] web Maven Webapp ................................... SUCCESS [  1.628 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.670 s
[INFO] Finished at: 2016-06-28T09:41:45+08:00
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /root/.jenkins/jobs/webapp-test/workspace/pom.xml to cn.codeforfun/webapp-test/1.0-SNAPSHOT/webapp-test-1.0-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/webapp-test/workspace/core/pom.xml to cn.codeforfun/core/1.0-SNAPSHOT/core-1.0-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/webapp-test/workspace/core/target/core-1.0-SNAPSHOT.jar to cn.codeforfun/core/1.0-SNAPSHOT/core-1.0-SNAPSHOT.jar
[JENKINS] Archiving /root/.jenkins/jobs/webapp-test/workspace/web/pom.xml to cn.codeforfun/web/1.0-SNAPSHOT/web-1.0-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/webapp-test/workspace/web/target/web.war to cn.codeforfun/web/1.0-SNAPSHOT/web-1.0-SNAPSHOT.war
channel stopped
Deploying /root/.jenkins/jobs/webapp-test/workspace/web/target/web.war to container Tomcat 7.x Remote
  Redeploying [/root/.jenkins/jobs/webapp-test/workspace/web/target/web.war]
  Undeploying [/root/.jenkins/jobs/webapp-test/workspace/web/target/web.war]
  Deploying [/root/.jenkins/jobs/webapp-test/workspace/web/target/web.war]
Finished: SUCCESS
--- 共有 5 条评论 ---
哎码回复 @西夏一品堂 : 区别在于tomcat是集成好的,如果你的shell是自己写的没有集成过的,那我估计就得用命令行了。可以选择构建之后运行shell,类似的这种,然后手动运行stop.sh/start.sh 1年前 回复
西夏一品堂回复 @哎码 : 我现在就想找,有没有这样的插件,可以直接在jenkins里面配置,就可以用的 1年前 回复
哎码回复 @西夏一品堂 : 都是类似的,只是容器不同而已,前提是jenkins支持 1年前 回复
哎码截取了一段控制台信息。大概流程是: 更新最新代码->cp了几个jvm的东东(不知道在干吗)->运行预先配置的maven命令(clean install)->jenkins maven归档->部署到tomcat容器中。 其中重要的就是:更新代码->maven 打包->部署到容器中。 1年前 回复
西夏一品堂我的项目不是放到tomcat里面的,也不需要tomcat,而是一个可以独立启动的应用 1年前 回复
你自己手动能完成jenkins就能完成,它只是帮你自动化了工作,不用你每次都做一样的动作而已
--- 共有 1 条评论 ---
西夏一品堂有没有现成的插件可以实现,我不想写shell去做 1年前 回复
顶部