wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
rpm download
rpm -ih '/root/下载/jenkins-2.89.1-1.1.noarch.rpm'
# 配置文件目录
/etc/sysconfig/jenkins
# 在该配置文件中,可以看到jenkins的主工作目录
JENKINS_HOME="/var/lib/jenkins"
service jenkins start
service jenkins stop
vi /etc/sysconfig/jenkins
#change the line:
JENKINS_PORT="8180"
环境变量
key: CLASSPATH
value: .:/usr/java/jdk1.8.0_151/lib/dt.jar:/usr/java/jdk1.8.0_151/lib/tools.jar
key: JAVA_HOME
value: /usr/java/jdk1.8.0_151
jenkins location
Jenkins URL: http://192.168.1.100:8180/
Extended E-mail Notification
SMTP server: smtp.exmail.qq.com
Default user E-mail suffix: @163.com
Use SMTP Authentication: User Name, Password, SMTP port, Charset
Default Content Type: HTML
Default Subject: ${BUILD_STATUS} - ${PROJECT_NAME} - Build # ${BUILD_NUMBER} !
Default Content:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"
offset="0">
<table width="95%" cellpadding="0" cellspacing="0"
style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td>(本邮件是程序自动下发的,请勿回复!)</td>
</tr>
<tr>
<td><h2>
<font color="#0000FF">构建结果 - ${BUILD_STATUS}</font>
</h2></td>
</tr>
<tr>
<td><br />
<b><font color="#0B610B">构建信息</font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<li>项目名称 : ${PROJECT_NAME}</li>
<li>构建编号 : 第${BUILD_NUMBER}次构建</li>
<li>触发原因: ${CAUSE}</li>
<li>构建日志: <a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
<li>构建 Url : <a href="${BUILD_URL}">${BUILD_URL}</a></li>
<li>工作目录 : <a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li>
<li>项目 Url : <a href="${PROJECT_URL}">${PROJECT_URL}</a></li>
</ul>
</td>
</tr>
<tr>
<td><b><font color="#0B610B">Changes Since Last
Successful Build:</font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<li>历史变更记录 : <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a></li>
</ul> ${CHANGES_SINCE_LAST_SUCCESS,reverse=true, format="Changes for Build #%n:<br />%c<br />",showPaths=true,changesFormat="<pre>[%a]<br />%m</pre>",pathFormat=" %p"}
</td>
</tr>
<tr>
<td><b>Failed Test Results</b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td><pre
style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">$FAILED_TESTS</pre>
<br /></td>
</tr>
<tr>
<td><textarea cols="80" rows="30" readonly="readonly"
style="font-family: Courier New">${BUILD_LOG, maxLines=100}</textarea>
</td>
</tr>
</table>
</body>
</html>
0 5 * * *
即每天的早上 5 点构建一次
id -gn
vi /etc/sysconfig/jenkins
JENKINS_USER="root"
sudo chown -R root /var/log/jenkins
sudo chgrp -R root /var/log/jenkins
sudo chown -R root /var/lib/jenkins
sudo chgrp -R root /var/lib/jenkins
sudo chown -R root /var/cache/jenkins
sudo chgrp -R root /var/cache/jenkins
JAVA_HOME=/usr/java/jdk1.8.0_151
CLASSPATH=.:/usr/java/jdk1.8.0_151/lib/dt.jar:/usr/java/jdk1.8.0_151/lib/tools.jar
mvn compile
//without parameters
mvn exec:java -Dexec.mainClass="com.vineetmanohar.module.Main"
//with parameters
mvn exec:java -Dexec.mainClass="com.vineetmanohar.module.Main" -Dexec.args="arg0 arg1 arg2"
# 或者使用maven-assembly-plugin打出可执行的jar包
java -cp target/api-executor-2.0.jar com.wz.APITestRunAssist localJsonFilePath=$jsonPath jobName=$JOB_NAME sendMessage=true
# 打印GC日志
java -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -Xloggc:/var/jenkins_home/gc.log -cp target/api-executor-2.0.jar com.wz.APITestRunAssist localJsonFilePath=$jsonPath jobName=$JOB_NAME sendMessage=true
# if you need to add one dns proxy on your hosts
vi /etc/hosts
# append one line
192.168.9.66 versiontestapp.com
shell
cd /var/lib/jenkins
chmod -R 777 workspace