-
Bug
-
Resolution: Unresolved
-
Critical
-
None
Jenkins build killed by script via https://<hostname>/script:
Jenkins.instance .getItemByFullName( <JOB_NAME> ) .getBuildByNumber( <BUILD_NUMBER> ) .finish( hudson.model.Result.ABORTED, new java.io.IOException( "Aborting build" ) )
Jenkinsfile
stage( 'do compile' ) { int result = 255 try { retry( count: 2 ) { result = sh ( returnStatus: true, script: "make all" ) } } catch ( org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e ) { def sw = new StringWriter() e.printStackTrace( new PrintWriter(sw) ) echo sw.toString() currentBuild.getRawBuild().getExecutor().interrupt( Result.ABORTED ) } finally { sh " exit ${result} " } }
result
- build got aborted
- stage still keeping "running" ( isActive : true )
stage detail:
import org.jenkinsci.plugins.workflow.job.* import org.jenkinsci.plugins.workflow.flow.* import io.jenkins.blueocean.rest.impl.pipeline.* import org.jenkinsci.plugins.workflow.cps.* import org.jenkinsci.plugins.workflow.graph.FlowNode WorkflowRun run = Jenkins.instance .getItemByFullName( <JOB_NAME> ) .getBuildByNumber( <BUILD_NUMBER> ) PipelineNodeGraphVisitor visitor = new PipelineNodeGraphVisitor(run) List<FlowNodeWrapper> flowNodes = visitor.getPipelineNodes() flowNodes.each { println """ ${it.getDisplayName()} stage : getRun() : ${it.getRun()} getResult : ${it.status.getResult()} getState : ${it.status.getState()} getType : ${it.getType()} getId : ${it.getId()} isRunning : ${it.node.running} isActive : ${it.node.active} """ }
- result
compile stage : getRun() : <JOB_NAME> #126603 getResult : ABORTED getState : FINISHED getType : STAGE getId : 54 isRunning : false isActive : true // <- this is not right
in stage view GUI:
in pipeline steps: