jenkins2 pipeline 语法快速参考

jenkins2 pipeline中常用的语法快速参考。

 

文章来自:http://www.ciandcd.com
文中的代码来自可以从github下载: https://github.com/ciandcd

来自:

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 3

 

完整实例:

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:


 

posted @ 2016-07-17 17:23  iTech  阅读(4336)  评论(0编辑  收藏  举报