kaur
kaur

Reputation: 627

Jenkins: Pass param from one multiphase job to next

I'm using multiphase job in Jenkins to do the following:

  1. PULL - Pull the workspace
  2. BUILD - Build the workspace and get artifact
  3. AUTOMATE - Run automation on artifact from step-2

I need to copy the artifact in AUTOMATE from a specific build in Step-2 BUILD. However, the BUILD_NUMBER for step-1 PULL and step-2 BUILD isn't same and afaik, artifacts are stored specific to build number.

Not sure how I can pass the BUILD_NUMBER from step-2 to step-3, as using 'current build parameters' doesn't bring in step-2 params to step-3.

I can't use 'Last Successful Build' as later i'll be running multiple jobs simultaneously on multiple instances.

I've and idea of storing the param in a file and read from there. But, i feel it more expensive and complex, and looking for a simpler alternative. Any ideas/help is appreciated.

Upvotes: 0

Views: 488

Answers (1)

333kenshin
333kenshin

Reputation: 2045

@kaur,

Use the Jenkins Promoted Build Plugin to save the build.

It gives you several env variables to work with:

  • PROMOTED_URL - URL of the job being promoted
  • PROMOTED_JOB_NAME - Promoted job name ex: job_name_being_promoted
  • PROMOTED_NUMBER - Build number of the promoted job ex: 77
  • PROMOTED_ID - ID of the build being promoted ex: 2012-04-12_17-13-03
  • PROMOTED_USER_NAME - the user who
  • triggered the promotion PROMOTED_JOB_FULL_NAME - the full name of the promoted job

Hope that helps.

Upvotes: 1

Related Questions