jenkins構建

1.點擊新建項目new item

2.選擇item類型進行創建,需注意:

  • Source Code Management:源碼是從SVN上拿的,所以選擇Subversion,在module-Repository URL上輸入SVN地址即可

  • build:root pom可以將一些配置設置在pom.xml文件中,Goals and options中應該寫的是一些操作,目前沒搞清楚(clean install cargo:redeploy -Dmaven.test.skip=true  -Ppom文件id

  • Build Settings:可以在Email中填寫觸發構建時收到通知的收件人地址

  • Post-build Actions:Projects to build填寫下一個進行構建的項目名稱

3.新建視圖new view,添加新建的item

4.需修改conf/tomcat-users.xml的user信息,添加manager


<role rolename="admin-gui"/>  
  
<role rolename="manager-gui"/>  
  
<user username="admin" password="admin" roles=" admin-gui , manager-gui "/>  


5.修改pom.xml文件,放在SVN上需要構建的文件夾下:


<profile>  
   <id>Goals and options提及的id</id>  
   <activation>  
       <property>  
           <name>profile</name>  
           <value>Goals and options提及的id</value>  
       </property>  
   </activation>  
  
   <properties>  
       <configDir>${basedir}/src/main/resources/一些放在SVN的配置文件</configDir>  
   </properties>  
  
   <build>  
       <plugins>  
           <plugin>  
               <groupId>org.apache.maven.plugins</groupId>  
               <artifactId>maven-compiler-plugin</artifactId>  
               <configuration>  
                   <source>1.7</source>  
                   <target>1.7</target>  
                   <encoding>UTF-8</encoding>  
               </configuration>  
           </plugin>  
           <plugin>  
               <groupId>org.codehaus.cargo</groupId>  
               <artifactId>cargo-maven2-plugin</artifactId>  
               <version>1.3.1</version>  
               <configuration>  
                   <update>true</update>  
                   <wait>true</wait>  
                   <path>/</path>  
                   <!-- |This is the configuration deploying / redeploying to remote   
                       tomcat, |so the remote tomcat config in tomcat-users.xml should add |<role   
                       rolename="manager"/> |<user username="xxxx" password="xxxx" roles="manager"/>. -->  
                   <container>  
                       <containerId>tomcat7x</containerId>  
                       <type>remote</type>  
                   </container>  
                   <configuration>  
                       <type>runtime</type>  
                       <properties>  
                           <cargo.hostname>構建地址</cargo.hostname>  
                           <cargo.servlet.port>8080構建端口</cargo.servlet.port>  
                           <cargo.remote.uri>構建地址/manager/text</cargo.remote.uri>  
                           <cargo.remote.username>tomcat-user名稱</cargo.remote.username>  
                           <cargo.remote.password>tomcat-user密碼</cargo.remote.password>  
                       </properties>  
                   </configuration>  
               </configuration>  
           </plugin>  
  
       </plugins>  
   </build>  
lt;/profile>  



6.部分Jenkins的配置可去/root/.m2/setting.xml更改

7.如果要在構建時執行shell命令:

  • 下載插件SSH plugin,下載完成後重啓Jenkins

  • 查看manager Jenkins-configure system,會多一項SSH remote hosts

  • 輸入Hostname、端口、用戶名、密碼後保存

  • 在新建的item中有一項Build Environment,勾選Execute shell script on remote host using ssh,SSH site中選擇設置好的地址,選擇構建前或構建後輸入需要執行的shell命令,注意地址/opt/XXX/XXX.sh

8.一切完成後直接點擊立即構建schedule a build


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章