ericmux
ericmux

Reputation: 138

Get Build Log from Jenkins Workflow script at runtime?

I'm writing a Groovy script for a build that needs to send and email with the build log in the message body. I was wondering if there was an easy way to read the current build output without having to pipe every step to a temporary file. This needs to happen while the build is still running.

Upvotes: 2

Views: 4632

Answers (2)

Psychobilly
Psychobilly

Reputation: 47

I am using this script to trigger email:

if (build.getLog().contains("FAILED")) 
{
  cancel = true;
}
else
{
  cancel = false;
}

You can find the available methods here.

Upvotes: 2

S.Spieker
S.Spieker

Reputation: 7385

I think you can get it also during build via the REST-API:

http(s)://<server-URL>/job/<job-Name>/lastBuild/consoleText

Upvotes: 2

Related Questions