Hi everyone!
I'm trying to build a Jenkins pipeline which executes other Jenkins jobs in a
particular order. I want to display each job's log in the pipeline, so here is
what I've came up with so far:
pipeline {
agent {
label 'pipeline'
}
stages {
stage('First') {
steps {
script {
def buildJob = ""
try {
buildJob = build job: 'First'
} finally {
println buildJob.rawBuild.log
}
}
}
}
stage('Second, Third') {
steps {
parallel (
"Second" : {
script {
def buildJob = ""
try {
buildJob = build job: 'Second'
} finally {
println buildJob.rawBuild.log
}
}
},
I have used the try-finally blocks so that the build log always will be
displayed, regardless of the buildJob outcome.
Interposed question: Would it be possible to get a 'live' log output while the
job is being build?
Anyhow, my problem is that I the second "println" will print the log of the
first job if the second job fails, not the log of the second job. This is why
I've added the def in the last script block, but this will yield an
unclassified field java.lang.String rawBuild error.
How could I work around this?
Thanks
Steffen
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/5E63738AB9896844AF1601A1D094677317A63160%40SMBXKO2.cgm.ag.
For more options, visit https://groups.google.com/d/optout.