jenkins2 pipeline中經常使用的語法快速參考。node
文章來自:http://www.ciandcd.com
文中的代碼來自能夠從github下載: https://github.com/ciandcdgit
來自:github
Using the Pipeline Plugin to Accelerate Continuous Delivery — Part 1
Using the Pipeline Plugin to Accelerate Continuous Delivery — Part 2
Using the Pipeline Plugin to Accelerate Continuous Delivery — Part 3web
完整實例:docker
stage 'build' node { git 'https://github.com/cloudbees/todo-api.git' withEnv(["PATH+MAVEN=${tool 'm3'}/bin"]) { sh "mvn -B –Dmaven.test.failure.ignore=true clean package" } stash excludes: 'target/', includes: '**', name: 'source' } stage 'test' parallel 'integration': { node { unstash 'source' withEnv(["PATH+MAVEN=${tool 'm3'}/bin"]) { sh "mvn clean verify" } } }, 'quality': { node { unstash 'source' withEnv(["PATH+MAVEN=${tool 'm3'}/bin"]) { sh "mvn sonar:sonar" } } } stage 'approve' timeout(time: 7, unit: 'DAYS') { input message: 'Do you want to deploy?', submitter: 'ops' } stage name:'deploy', concurrency: 1 node { unstash 'source' withEnv(["PATH+MAVEN=${tool 'm3'}/bin"]) { sh "mvn cargo:deploy" } }
語法參考卡:
基本:
高級:
文件操做:
流程控制:
docker: