Jenkins - passing variables between jobs?

前端 未结 10 1657
你的背包
你的背包 2020-11-28 06:53

I have two jobs in jenkins, both of which need the same parameter.

How can I run the first job with a parameter so that when it triggers the second job, the same pa

10条回答
  •  长情又很酷
    2020-11-28 07:28

    (for fellow googlers)

    If you are building a serious pipeline with the Build Flow Plugin, you can pass parameters between jobs with the DSL like this :

    Supposing an available string parameter "CVS_TAG", in order to pass it to other jobs :

    build("pipeline_begin", CVS_TAG: params['CVS_TAG'])
    parallel (
       // will be scheduled in parallel.
       { build("pipeline_static_analysis", CVS_TAG: params['CVS_TAG']) },
       { build("pipeline_nonreg", CVS_TAG: params['CVS_TAG']) }
    )
    // will be triggered after previous jobs complete
    build("pipeline_end", CVS_TAG: params['CVS_TAG'])
    

    Hint for displaying available variables / params :

    // output values
    out.println '------------------------------------'
    out.println 'Triggered Parameters Map:'
    out.println params
    out.println '------------------------------------'
    out.println 'Build Object Properties:'
    build.properties.each { out.println "$it.key -> $it.value" }
    out.println '------------------------------------'
    

提交回复
热议问题