deebee
deebee

Reputation: 1747

Jenkins Pipeline script - return value of a build step

Is there a way to fetch URL of a build step (without waiting for completion) through Jenkins pipeline script?

Here is what I've tried but the return value of build is null.

def build_job = build job: 'dummy_job', wait: false

Trying to fetch URL as follows: build_job.absoluteUrl

Upvotes: 8

Views: 5639

Answers (2)

yorammi
yorammi

Reputation: 6458

You can get it by using the getRawBuild() method:

   def build_job=build(job:'dummy_job',propagate:false)
   echo build_job.getResult()
   echo build_job.getRawBuild().getAbsoluteUrl()

Don't use wait: false since the function won't return the expected result. propagate: false is so that the current job won't abort (fail before the next step) if the called job fails.

Upvotes: 5

sai
sai

Reputation: 450

BUILD_URL should provide you the job url. You can get all environment variables in the pipeline using env bash command.

Jenkins doc: here

Upvotes: -2

Related Questions