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
Execution of the pipeline stages can be controlled with conditions. These conditions must be defined in the when block within each stage. Jenkins supports a set of significant conditions that can be defined to limit stage execution. Each when block must contain at least one condition.
returnStdout : boolean (optional) If checked, standard output from the task is returned as the step value as a String , rather than being printed to the build log. (Standard error, if any, will still be printed to the log.) You will often want to call . trim() on the result to strip off a trailing newline.
On Linux, BSD, and Mac OS (Unix-like) systems, the sh step is used to execute a shell command in a Pipeline. Jenkinsfile (Declarative Pipeline) pipeline { agent any stages { stage('Build') { steps { sh 'echo "Hello World"' sh ''' echo "Multiline shell steps works too" ls -lah ''' } } } }
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 the wait: false
since the function won't return the expected result.
don't use the propagate: false
so the job won't fail before the next step if the called job fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With