Dear Christoph,

We implemented your proposed solution via the Groovy Plugin and it worked
ok to test for success patterns after each build step.

Thank you very much ,

Regards,
Stefano

_______________________________________________

Ing. Stefano Perticoni
Super Computing Solutions s.r.l.
http://www.scsitaly.com
Via Parini 1, 40033 Casalecchio di Reno BO, Italy
mailto: s.pertic...@scsitaly.com
_______________________________________________


On Tue, Nov 29, 2011 at 10:37 PM, Christoph VogtlÃĪnder
<jenk...@mockies.de>wrote:

> Hi,
>
> On Tuesday 29 November 2011 12:53:50 stefano perticoni wrote:
> > Dear jenkins users,
> >
> > I'm new to jenkins and currently trying to replicate the build workflow
> we
> > are using with another continous integration server.
> >
> > Here is the trivial question :-)  !
> >
> > Is there any plugin to add, to a single build step, the capability to
> parse
> > its output log and mark the step as failed if the condition is not
> matched?
>
> AFAIK there is no plug-in that will do this out of the box. As mentioned by
> Didier you can use the Log Parser Plugin [1]. I prefer the Groovy Postbuild
> Plugin [2] (using "manager.logContains(regexp)"). But both plug-ins only
> parse
> the log at the end of the build, not between build steps.
>
> To test the log output after every build step you can use the Groovy Plugin
> [3] which adds the possibility to execute system groovy code as a build
> step
> (at least in Free Style Projects).
> You can use the following code:
> --------------------------------------------------
> def pattern = /^build FAILED$/
>
> def build = Thread.currentThread().executable, result = 0
> // Parsing 5 most recent lines of the build log
> log = build.getLog(5)
> for (line in log) {
>  if (line ==~ pattern) {
>    result = 1
>    break
>  }
> }
> return result
> --------------------------------------------------
>
> Hope this helps. Btw, it would be much easier (and system conform) if your
> build step would return/exit with a non zero exit code directly.
> --
> Christoph
>
>
> [1] https://wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin
> [2] https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin
> [3] https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Plugin
>
>

Reply via email to