Don Giulio
Don Giulio

Reputation: 3304

How to write a promotion job for multiple upstream projects in Jenkins?

I have quite many build projects in jenkins (several projects with several branches each), I would like to enable them for promotion (using the promotion plugin).

The promotion process would be pretty much the same for all the different jobs. So I wouldn't like to write all the promotion steps in each of the build projects, but rather have a single promotion job, able to promote them.

The way I see it a user would manually select and promote one build from either build project. the build would trigger a new build of the promotion job, which retrieves the information from the promoted build and does the promotion.

My problem is that I don't seem to see a way to retrieve the artifacts from the promoted build.

If I use the copy artifact plugin it forces me to choose an upstream job, and I seem not to be able to write more than one. The help says that I can use the $ variables, but I don't see how, as I don't see the promoted build id among the environment variables.

I'm pretty sure this could be solved, but I don't see how.

Anyone has an idea?

thanks.

Upvotes: 4

Views: 1360

Answers (1)

Jason Swager
Jason Swager

Reputation: 6501

When a promotion runs, there are two variables created during the promotion that refer back to the original job. They are:

  • PROMOTED_JOB_NAME: The name of the original job.
  • PROMOTED_NUMBER: The original build number of the original job.

You can use these in actions attached to the promotion to reference the original job. I use them with the Copy Artifacts plugin to retrieve archived files from the original build, then do things like copy to the network, publish, etc.

Upvotes: 2

Related Questions