jenkins2 Jenkinsfile


推薦使用Jenkinsfile代替將groovy腳本直接寫在jenkins job里。

 

文章來自:http://www.ciandcd.com
文中的代碼來自可以從github下載: https://github.com/ciandcd

 

推薦將pipeline的groovy腳本放到Jenkinsfile且保存到跟源代碼相同的目錄下。通過這種方法實現了groovy腳本與源代碼都被版本控制,更好地支持構建的可重現性。

本文用到的測試repo:https://github.com/ciandcd/simple-maven-project-with-tests.git

測試repo下的Jenkinsfile:https://github.com/ciandcd/simple-maven-project-with-tests/blob/master/Jenkinsfile

 

1. Jenkinsfile的內容如下:

node (){
stage 'Build and Test'
env.PATH = "${tool 'M3'}/bin:${env.PATH}"
//checkout scm
git url:"https://github.com/ciandcd/simple-maven-project-with-tests.git"
sh 'mvn clean package'
}

 

2. 配置jenkins pipleline job來使用Jenkinsfile

 

3. 運行pipleline job將會看到如下view

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM