0

I have already looked at How to mark a build unstable in Jenkins when running shell scripts. But none of the solution covers the fact that I want to mark my matrix parent as unstable rather than failure.

Code I have currently using the groovy post build solution to check the file,

import java.io.InputStream
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;

def build = Thread.currentThread().executable

String unstable = null
if(build.workspace.isRemote()) {
    channel = build.workspace.channel;
    fp = new FilePath(channel, build.workspace.toString() + "/build.properties")
    InputStream is = fp.read()
    unstable = is.text.trim()
} else {
    fp = new FilePath(new File(build.workspace.toString() + "/build.properties"))
    InputStream is = fp.read()
    unstable = is.text.trim()
}

manager.listener.logger.println("Build status file: " + unstable)
if (unstable.equalsIgnoreCase('true') && manager.buildIsA(MatrixBuild.class)) {
    manager.listener.logger.println('setting build to unstable')
    manager.buildUnstable()
   manager.build.@result = hudson.model.Result.UNSTABLE
} 

In the last if block if I use manager.buildIsA(MatrixRun.class), I could make all the child jobs as unstable, but my requirement is to mark the matrix parent job as unstable. Does the groovy post build script never run on the matrix parent job? Any help is appreciated.

OT_DEV
  • 161
  • 1
  • 1
  • 10
  • I found another post which alludes that post build actions are not performed after the matrix parent job. So I think it wont be possible to do this after all. We might need to change to using pipeline jobs to achieve this. – OT_DEV Sep 23 '22 at 16:36

0 Answers0