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


要使用Jenkins构建项目,您需要完成以下几个步骤: 1. 首先,您需要在系统中安装JDK并配置环境变量。根据引用中的指导,您可以使用以下命令来安装JDK并设置JAVA_HOME环境变量: ``` yum -y update && yum -y install java-1.8.0-openjdk* vim /etc/profile export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar export PATH=$PATH:$JAVA_HOME/bin ``` 这将确保您的系统具有正确的Java环境。 2. 安装Git。您可以使用以下命令在系统上安装Git: ``` yum install -y git ``` 使用命令`whereis git`可以查看Git的安装路径。 3. 安装Jenkins。您可以根据您的系统环境选择适当的安装方法。根据引用中的指导,您可以使用以下命令来安装Maven: ``` cd /usr/local wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz tar -vzxf apache-maven-3.5.4-bin.tar.gz mv apache-maven-3.5.4 maven ``` 这将下载并解压Maven安装包。 4. 配置Jenkins。启动Jenkins并访问其Web界面。根据Jenkins的安装和配置指南,您将需要设置管理员用户名和密码,并安装所需的插件。 5. 创建Jenkins任务。在Jenkins中,您可以创建一个新的任务来构建您的项目。根据您的项目类型和需求,您可以选择不同的构建方式和操作。 请注意,这里提供的步骤只是一般的指导,具体的配置和操作可能因您的系统环境和项目要求而有所不同。建议您参考Jenkins的官方文档和相关资源以获取更详细的指导。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值