[workflow-plugin] Exposing RunWrapper.getLog() methods for workflow build step (or alternate way to retrieve build-step logs)

145 views
Skip to first unread message

Vizionz

unread,
Jun 10, 2015, 3:36:43 PM6/10/15
to jenkins...@googlegroups.com
Hi All -

I'm looking to find means of obtaining job (console) logs from build steps in a workflow.  Any help is greatly appreciated!

In the workflow script below, I am creating a map that contains that contains a build-step of 'TestJenkinsJob'.  After the job is completed, I check the results for a failure.  Is there way to access the job's logs?

I see that the RunWrapper does not expose any api to retrieve Run.getLogFile().

Many Thanks!
-Vizionz

// Allocate Node
//////////
node("MyNode")
{
// Set Directory
//////////
dir("PathToDirectory")
{
// Map of builds for parallel execution
/////////
def buildMap = [:]
// Setup JOB_1
/////////
buildMap["JOB_1"] = {
// Start a test job.
/////////
def jobInfo = build job: 'TestJenkinsJob', propagate: false
if (jobInfo.getResult() == "FAILURE")
{
// Access logfile of job - NOT EXPOSED in RunWrapper
//////////
def failLog = jobInfo.getLogFile()
println "FAIL_LOG\n$failLog"
// ... Do more work with fail log (save/parse/report/etc.)
}
}
// Setup JOB_2
//////////
buildMap["JOB_2"] = {
// ... Setup Job 2
}
// Start the parallel job
/////////
parallel buildMap
}
}


 

Eric Engel

unread,
Jun 11, 2015, 6:14:32 AM6/11/15
to jenkins...@googlegroups.com

Hi,

 

I got the same problem and it can work by thinking a little bit outside the box.

You can get the jobs BUILD_NUMBER value through the getNumber() method. With that you may access the plain log via <Jenkins-server>/job/<jobname>/<buildnumber>/consoleText URL.

 

Regards

Eric

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1b15af84-4ec4-415f-8c1d-7391fb4daec8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vizionz

unread,
Jun 11, 2015, 8:16:25 PM6/11/15
to jenkins...@googlegroups.com, e...@ivu.de

You can get the jobs BUILD_NUMBER value through the getNumber() method. With that you may access the plain log via <Jenkins-server>/job/<jobname>/<buildnumber>/consoleText URL.

 

Regards

Eric


This definitely works!

I was hoping that there would be a way to access the logs without hitting a URL.  

Many Thanks Eric

Jesse Glick

unread,
Jun 16, 2015, 2:14:31 PM6/16/15
to jenkins...@googlegroups.com
On Wednesday, June 10, 2015 at 3:36:43 PM UTC-4, Vizionz wrote:
I see that the RunWrapper does not expose any api to retrieve Run.getLogFile().

Did you try wrapper.rawBuild.log?
Reply all
Reply to author
Forward
0 new messages