Exit Conditional Build Step when error text appears

146 views
Skip to first unread message

calvin...@bfusa.com

unread,
Dec 7, 2015, 3:17:57 PM12/7/15
to Jenkins Users

I have a Jenkins project with several conditional build steps.  I would like for Jenkins to exit out of the build if it encounters an error code in ANY of the build steps.  It is not recognizing the Clearcase cleartool error code – Result: 1 and marks the step as successful and continues on to the next build step.  I have tried the Text Finder plug-in, but this only runs at the END of all of the build steps, which is too late.  How can I have Jenkins search the console output after a build step and exit the build if it finds an error?

 

See output example below.

 

 

updateManifest:

     [exec] Set activity "Manifest_update" in view "SCMBuild_TestBld_CredTst".

     [exec] cleartool: Error: Element "MANIFEST.MF" is already checked out to view "SCMBuild_TestBld_CredTst".

     [exec] Result: 1

     [exec] cleartool: Error: By default, won't create version with data identical to predecessor.

     [exec] cleartool: Error: Unable to check in "MANIFEST.MF".

     [exec] Result: 1

     [exec] cleartool: Error: Element "AAS-SSO.ear" is already checked out to view "SCMBuild_TestBld_CredTst".

     [exec] Result: 1

 

BUILD SUCCESSFUL

Total time: 2 seconds

[Current build status] check if current [SUCCESS] is worse or equals then [SUCCESS] and better or equals then [SUCCESS]

Run condition [Current build status] enabling perform for step [Invoke Ant]

[Jenkins] $ cmd.exe /C '"C:\apache-ant-1.9.6\bin\ant.bat -file build.scm.xml -DclearcaseStream=SCMBuild_TestBld_CredTst -DConfigDocumentDirectory=N/A -DprojectVob=p_test-parent -Dbuildpath=test-parent\TestBld\BF_AAS_SSO -DclearcaseView=SCMBuild_TestBld_CredTst -DartifactList=AAS-SSO.ear -DbuildIncrement=02 -DprojectName=CREDTST -DdeveloperBaseline=TST_CredTstParent_20151207_01 -DSTATIC.cleartool=C:\IBM\RationalSDLC\ClearCase\bin\cleartool.exe -DapplicationName=TestBld checkInArtifacts && exit %%ERRORLEVEL%%"'

Buildfile: C:\SCM\Jenkins\build.scm.xml

 

checkInArtifacts:

     [exec] cleartool: Warning: Activity being unset "activity:Manifest_update@\p_test-parent" has checkouts.

     [exec] Set activity "CREDTST_QA_BLD" in view "SCMBuild_TestBld_CredTst".

     [echo] Checking in artifact - M:\SCMBuild_TestBld_CredTst\TestBld_Deploy\Artifacts\AAS-SSO.ear

     [exec] Checked in "AAS-SSO.ear" version "\main\SCMBuild_TestBld_CredTst\3".

     [exec]   Attached activity:

     [exec]     activity:Manifest_update@\p_test-parent  "Manifest_update"

 

BUILD SUCCESSFUL

Total time: 2 seconds

Run condition [Never] preventing perform for step [Invoke Ant]

Checking console output

C:\Program Files (x86)\Jenkins\jobs\Parent Test Project\builds\36\log:

     [exec] Result: 1

Build step 'Jenkins Text Finder' changed build result to UNSTABLE

Finished: UNSTABLE

Victor Martinez

unread,
Dec 8, 2015, 2:49:02 AM12/8/15
to Jenkins Users
Hi,

IMO, you might need to fix your ant script rather than hacking your build steps, in case you want to hack your jobs look at 1) otherwise see my suggestions 2) which is not a Jenkins question IMO, but I hope it helps.

1) validating build step afterwards
using a system groovy step you can access the Jenkins model and query the current build, what I'm not 100% sure whether those previous build steps are already part of the model or still on the fly/memory.
There are some examples if you look at the acriptler or post build groovy plugins.

2) ant - errorleves

If you use ant can you double check if you trap those errorlevels in the mentioned target? Either using the failonerror attribute or postprocessing those errors in another target via the fail task (as an example)

You can also double check when running those steps locally if the errorlevel is non-zero.

I hope it helps

Reply all
Reply to author
Forward
0 new messages