Jenkins build flow plugin

Jenkins build flow plugin

关于build flow plugin

概要

This plugin is designed to handle complex build workflows (aka build pipelines) as a dedicated entity in Jenkins.
Without such a plugin, to manage job orchestration the user has to combine parameterized-build, join, downstream-ext
and a few more plugins, polluting the job configuration.
The build process is then scattered in all those jobs and very complex to maintain.
Build Flow enables you to define an upper level Flow item to manage job orchestration and link up rules,
using a dedicated DSL. This DSL makes the flow definition very concise and readable.

配置

基础

  1. 定义了job 序列 ```
    build( "job1" )
    build( "job2" )
    build( "job3" )
2. 定义一个环境变量通过下面的方式 ```  
def revision = b.environment.get("GIT_REVISION")  
  1. 预定义的变量 ```
    You can also access some pre-defined variables in the DSL :

"build" the current flow execution "out" the flow build console "env" the flow environment, as a Map "params" triggered parameters "upstream" the upstream job, assuming the flow has been triggered as a downstream job for another job.

4. Guard/ Rescue

执行结束之后的收尾工作, 如java里的try-finally块.

guard {
build( "thisjobmay_fail" ) } rescue { build( "cleanup" ) }

5. ignore

一个任务的结果可以忽略的. 他们在你的flow里可以被忽略.使用 `ignore` 块

ignore(FAILURE) {
build( "sendtwitternotification" ) }

6. 重试
retry ( 3 ) {
    build( "this_job_may_fail" )
}       
7. parallel

flow是一个严格定义的序列.但是能够并行执行,等待完成.

parallel (
// job 1, 2 and 3 will be scheduled in parallel. { build("job1") }, { build("job2") }, { build("job3") } ) // job4 will be triggered after jobs 1, 2 and 3 complete build("job4")

parallel区别于join插件的就是它可以串联很多的并行

parallel (
{ build("job1A") build("job1B") build("job1C") }, { build("job2A") build("job2B") build("job2C") } )

另外, 它还可以和其他的结合关键字混用:

parallel (
{ guard { build("job1A") } rescue { build("job1B") } }, { retry 3, { build("job2") } } ) ```

扩展点