jenkins + maven + svn

來源:互聯網
上載者:User
工具準備: Jenkins 1.65 官網 https://jenkins.io/index.html Maven 3 Jdk 1.7 Eclpse 4.6 開始: 準備一個maven項目:根據這個來就可以http://www.cnblogs.com/leiOOlei/p/3361633.html,需要注意的是,有可能會找不到 “further configuration available”,這個時候把“Dynamic web module”勾掉,然後退出再進就可以了,奇葩。搞定之後上傳svn即可。 Jenkins的安裝:本想用jenkins2.7,但是外掛程式總是安裝失敗,最終下載1.65版的war,war版本的好處在於放到tomcat裡直接就可以用了。可根據這個一步一步即可:http://www.cnblogs.com/sunzhenchao/archive/2013/01/30/2883289.html Svn中文目錄不識別的問題,在確認tomcat設定了編碼格式的前提下,我是採用在jenkins中升級外掛程式到最新版本的方式解決的(無奈自動下載失敗,直接手動下載外掛程式,然後在控制台中可手動上傳安裝成功的) 執行構建,發生錯誤,Maven編譯問題,需要在Maven的setting.xml檔案中增加
<profile>        <id>jdk-1.7</id><activation><activeByDefault>true</activeByDefault><jdk>1.7</jdk></activation><properties><maven.compiler.source>1.7</maven.compiler.source><maven.compiler.target>1.7</maven.compiler.target><maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion></properties></profile>


在你項目的pom.xml中增加
     <plugins>         <plugin>             <groupId>org.apache.maven.plugins</groupId>             <artifactId>maven-compiler-plugin</artifactId>             <version>3.1</version>             <configuration>                 <source>1.7</source>                 <target>1.7</target>                 <encoding>UTF-8</encoding>             </configuration>         </plugin>     </plugins>
構建過程中,可能還會報編碼異常,需要在你項目的pom.xml中增加
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
自動發布到tomcat的話,需要安裝外掛程式,不太好找,在外掛程式裡搜一下aplication server,應該就能找到,需要配置tomcat的tomcat-users.xml,開啟注釋:
<role rolename="manager-gui"/>  <role rolename="manager-script"/>  <role rolename="manager-jmx"/>  <role rolename="manager-status"/>  <user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status"/>  
這裡還需要確保你的tomcat中的root下有那個manger的原始項目 第一個jenkins配置成功,留念:
Started by user anonymousBuilding in workspace C:\Users\Administrator\.jenkins\jobs\MiceRp\workspaceUpdating https://101.201.148.185/svn/沙箱/Mice/MiceRp at revision '2016-08-01T12:15:38.694 +0800'D         src\main\java\log4j.propertiesD         src\main\java\hanlp.propertiesA         src\main\resources\hanlp.propertiesA         src\main\resources\log4j.propertiesAt revision 543Parsing POMs[workspace] $ E:\Jdk\jdk1.7.0_80/bin/java -cp C:\Users\Administrator\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;E:\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;E:\apache-maven-3.3.9/conf/logging jenkins.maven3.agent.Maven31Main E:\apache-maven-3.3.9 E:\Web\apache-tomcat-7.0.65-jenkins\webapps\jenkins\WEB-INF\lib\remoting-2.59.jar C:\Users\Administrator\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar C:\Users\Administrator\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar 53612<===[JENKINS REMOTING CAPACITY]===>channel startedExecuting Maven:  -B -f C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\pom.xml install[INFO] Scanning for projects...[INFO]                                                                         [INFO] ------------------------------------------------------------------------[INFO] Building MiceRp Maven Webapp 0.0.1-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MiceRp ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 13 resources[INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MiceRp ---[INFO] Nothing to compile - all classes are up to date[INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MiceRp ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 0 resource[INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MiceRp ---[INFO] Nothing to compile - all classes are up to date[INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MiceRp ---[JENKINS] Recording test results[INFO] [INFO] --- maven-war-plugin:2.2:war (default-war) @ MiceRp ---[INFO] Packaging webapp[INFO] Assembling webapp [MiceRp] in [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp][INFO] Processing war project[INFO] Copying webapp resources [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\src\main\webapp][INFO] Webapp assembled in [383 msecs][INFO] Building war: C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war[INFO] WEB-INF\web.xml already added, skipping[INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ MiceRp ---[INFO] Installing C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war to C:\Users\Administrator\.m2\repository\com\mice\rp\MiceRp\0.0.1-SNAPSHOT\MiceRp-0.0.1-SNAPSHOT.war[INFO] Installing C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\pom.xml to C:\Users\Administrator\.m2\repository\com\mice\rp\MiceRp\0.0.1-SNAPSHOT\MiceRp-0.0.1-SNAPSHOT.pom[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 9.294 s[INFO] Finished at: 2016-08-01T12:16:06+08:00[INFO] Final Memory: 18M/156M[INFO] ------------------------------------------------------------------------[JENKINS] Archiving C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\pom.xml to com.mice.rp/MiceRp/0.0.1-SNAPSHOT/MiceRp-0.0.1-SNAPSHOT.pom[JENKINS] Archiving C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war to com.mice.rp/MiceRp/0.0.1-SNAPSHOT/MiceRp-0.0.1-SNAPSHOT.warchannel stoppedDeploying C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war to container Tomcat 7.x Remote  Redeploying [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war]  Undeploying [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war]  Deploying [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war]Finished: SUCCESS
原文地址:http://blog.csdn.net/yueritian/article/details/52084575




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.