【環境】maven、git
1、新建項目
【General】
Paste_Image.png
【源碼管理】
Paste_Image.png
【構建觸發器】
Paste_Image.png
【構建環境】
Paste_Image.png
【構建】
Paste_Image.png
Goals
clean install -U -P test findbugs:findbugs checkstyle:checkstyle
說明:-U 強制更新maven庫中的依賴包,nexus默認是當天更新,第二天才能生效調用。
-P test :調用pom配置中的test環境參數
findbugs:findbugs checkstyle:checkstyle :執行靜態檢查
【Execute Shell】
Paste_Image.png
echo "項目名稱:" $JOB_NAME >>version.txt
echo "git版本號:" $GIT_COMMIT >>version.txt
echo "構建編號:" $BUILD_NUMBER >>version.txt
jar uvf target/test1*.war version.txt
scp -r ~/.jenkins/workspace/projectname/target/*.war root@192.168.1.xx1:/home/yuanfang/totest/eid_forpolice/test1.war
scp -r ~/.jenkins/workspace/projectname/target/*.war root@192.168.1.xx2:/usr/local/tomcat-test-8081/webapps/test1.war
ssh -tt 192.168.1.xx2 "/opt/restart.sh"
【構建后操作】
Paste_Image.png
【Editable Email Notifaction】
Paste_Image.png
Paste_Image.png
Paste_Image.png