Change build status to succes in jenkins
Asked Answered
W

1

8

My jenkins jobs use testlink to store their test results. The testlink plugin changes the build status to unstable if a test has failed.

However I want the build result to be determind by Xunit plugin in a post-build action because with Xunit you can adapt a failure threshold. The build should only be unstable if there are new errors.

I was hoping to do the following:

--test--

--testlink -> marked as unstable --

-- groovy scipt --> marked as succes --

build.result = hudson.model.Result.SUCCESS

-- xunit, checks threshold for unstable/succes --

However it seems impossible to change the build status back to success. So now testlink marks as unstable, and xunit mirros that status.

Is there a way to work around this problem?

Wille answered 29/8, 2016 at 12:39 Comment(0)
K
6

Unfortunately, I don't think Jenkins will allow you to do that without an ugly hack.

For example, you can see a comment that clearly states that a result can only get worse in the Jenkins source code

e.g.

462 // result can only get worse
463 if (result==null || r.isWorseThan(result)) {

That being said....

Once the job is done, you can "technically" log on to the master and do whatever you want to already completed builds via changing the build.xmls directly.

For example, you could add a post build job that will go through the files on Jenkins master and do a mass update to replace "<result>UNSTABLE</result>" to "<result>SUCCESS</result>" to turn all builds to success. Once the job is done, forcefully restart the Jenkins server or reload its configuration for the changes to take effect.

I don't recommend this as who knows what will happen to Jenkins if you start going crazy like this. ;)

Kaiserism answered 30/8, 2016 at 2:52 Comment(5)
Have you not seen the Groovy Post Build plugin? It can do this.Phenyl
@Phenyl how? Can you share the groovy script please?Nares
Sure. Read this page. tikalk.com/devops/JenkinsJobStatusChangePhenyl
I know it is little late, but where are jobs result files stored exactly?Appellant
Couldn't we use reflection to access the result field, make it public, and set the underlying field to whatever value we want? I'm not sure if the fact the field is declared as volatile would do anything to mess this plan up...Lagrange

© 2022 - 2024 — McMap. All rights reserved.