Jenkins - How to get and use upstream info in downstream

前端 未结 5 1479
我在风中等你
我在风中等你 2020-12-25 15:15

Executing upstream job called \"A\". On success of A executing test cases which is downstream project \"B\". But while sending mail from B we have to incorporate upstream pr

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-25 16:19

    You can pass in the upstream variables via build parameters to the downstream job and then you can access them (in the downstream job) using things such as ${MyParameter1} and ${MyParameter2}.

    You would need to:

    1. Add build parameters to the downstream job. For example, a string parameter named "ParentJobName".
    2. Add a post build "Trigger downstream parameterized builds on other projects" to the upstream job.
    3. Add something like "Current Build parameters" or "Predefined parameters" to the #2 and pass in whatever you need. For example: ParentJobName=${JOB_NAME}
    4. Access the parameters as you would other build variables. e.g. ${ParentJobName}

    You should be able to pass in the basic stuff that way. Anything more complicated than that and you will probably be better off using a plugin like Copy Artifacts Plugin to copy files or using the Jenkins API in a system groovy step to get/modify the upstream build, etc.

提交回复
热议问题