Jenkins - passing variables between jobs?

前端 未结 10 1656
你的背包
你的背包 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:29

    I think the answer above needs some update:

    I was trying to create a dynamic directory to store my upstream build artifacts so I wanted to pass my upstream job build number to downstream job I tried the above steps but couldn't make it work. Here is how it worked:

    1. I copied the artifacts from my current job using copy artifacts plugin.
    2. In post build action of upstream job I added the variable like "SOURCE_BUILD_NUMBER=${BUILD_NUMBER}" and configured it to trigger the downstream job.
    3. Everything worked except that my downstream job was not able to get $SOURCE_BUILD_NUMBER to create the directory.
    4. So I found out that to use this variable I have to define the same variable in down stream job as a parameter variable like in this picture below:

    This is because the new version of jenkins require's you to define the variable in the downstream job as well. I hope it's helpful.

提交回复
热议问题