Jenkins Pipeline - build job step, ability to return build job number

36 views
Skip to first unread message

Kai

unread,
Dec 22, 2017, 1:31:54 PM12/22/17
to Jenkins Users
Hi,

We are using Jenkins Pipeline - build job step and wanted the ability to return build job number so that we can use the build job # in the next step.

e.g.
buildJobNumber=build job: 'my-test-job', parameters: [string(name: 'environment', value: 'QA')], quietPeriod: 10

Then be able to use buildJobNumber in the next stage.

Thanks


Victor Martinez

unread,
Dec 23, 2017, 6:35:42 AM12/23/17
to Jenkins Users
The build job step returns a RunWrapper object, and in your case you can use the getId method

def buildObj = build job: 'my-test-job', parameters: [string(name: 'environment', value: 'QA')], quietPeriod: 10
echo buildObj.getId()

Cheers

Kai

unread,
Dec 24, 2017, 2:44:11 PM12/24/17
to Jenkins Users
wow, thanks so much!
Reply all
Reply to author
Forward
0 new messages