Jenkins - passing variables between jobs?

前端 未结 10 1660
你的背包
你的背包 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 07:11

    I faced the same issue when I had to pass a pom version to a downstream Rundeck job.

    What I did, was using parameters injection via a properties file as such:

    1) Creating properties in properties file via shell :

    Build actions:

    • Execute a shell script
    • Inject environment variables

    E.g : properties definition

    2) Passing defined properties to the downstream job : Post Build Actions :

    • Trigger parameterized build on other project
    • Add parameters : Current build parameters
    • Add parameters : predefined parameters

    E.g : properties sending

    3) It was then possible to use $POM_VERSION as such in the downstream Rundeck job.

    /!\ Jenkins Version : 1.636

    /!\ For some reason when creating the triggered build, it was necessary to add the option 'Current build parameters' to pass the properties.

提交回复
热议问题