前提已經安裝相關插件(根據自己的版本管理選擇相應的插件,這裏用的Git)
pipline設置:
注意圈起來的是腳本的路徑,默認是Jenkinsfile,然後你需要在代碼庫的根目錄下創建一個Jenkinsfile的文件,將你的pipline代碼寫進去(或者可以在根目錄下創建一個pipline文件夾,在裏面放置一個Jenkinsfile文件)。需要注意的是,設置和跟目下的文件名路徑一定要一致。
根目錄下的Jenkinsfile:
pipeline{
agent any
tools {
maven 'M 3'
}
stages{
stage("checkout code"){
steps {
script{
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'JS122121qY12237PXD0E6Nxrn6Xhb', url: 'https://github.com/XXXXXXX']]])
//echo "Create folder to store json files"
//bat 'mkdir reportJsonFiles'
}}
}
stage("run test case"){
steps {
script{
//your code
}}
}
}
post('Generate report') {
always {
script{
//your code
}}}
}
build結果圖: