asur
asur

Reputation: 1879

How should I tag Pipeline Number under a Jenkins Job

I have create a new Pipeline "test". Under this Pipeline I have three jobs.

Job No#-

A- Build B- Test C- Publish

If I "Run" pipeline, all the three jobs get executed one after the other.

My Issue- How should I get Job A's Build No# as my Tag in Job C.(To track).

enter image description here

Error Logs--

> C:\Program Files (x86)\Git\bin\git.exe tag -l 9 # timeout=10
ERROR: Step ‘Git Publisher’ failed: Tag 9 already exists and Create Tag is specified, so failing.

enter image description here

Upvotes: 0

Views: 693

Answers (1)

Pom12
Pom12

Reputation: 7880

You can use Parameterized Builds to accomplish that. Basically, what you want to do is pass the build number of job A from job A down to job C as a parameter, as described in the above schema :

enter image description here

To do that, you have to :

  • Pass a parameter JOB_A_BUILD_NUMBER from job A to B using "trigger parameterized build" in job A.
  • Pass a parameter JOB_A_BUILD_NUMBER from job B to C using "trigger parameterized build" in job B.
  • Use this parameter as a variable in your Git publisher using $JOB_A_BUILD_NUMBER.

To configure a parameterized job, you can just do that :

enter image description here

Upvotes: 1

Related Questions