I try to select all current running processes to get the BuildNumber
an JobName
of the running pipelines to finaly have the possibility to kill them.
However, if I use the Jenkins API to collect the BuildNumber
and JobName
I will get as return:
[(master)]:
[org.jenkinsci.plugins.workflow.job.WorkflowJob@6b41187c[myPipeline], org.jenkinsci.plugins.workflow.job.WorkflowJob@6296243a[myDeploy]]
I assumed that "@6296243a[myDeploy]" is the information I need. But the "6296243a" is not a valid BuildNumber
. I really do not know what this number stands for. Maybe the process id.
The "myDeploy" is the JobName
I need to have.
So my question why I will not get a valid "BuildNumber" here?
import jenkins.model.*
import hudson.model.*
def result = []
def buildingJobs = Jenkins.instance.getAllItems(Job.class).findAll {
it.isBuilding()
}
println buildingJobs
Finaly I want to use the both information at:
Jenkins.instance
.getItemByFullName(<JobName>)
.getBuildByNumber(<BuldNumber>)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
if I use here the values BuildNumber: 6296243a
JobName: myDeploy
it will not work. If I use the BuildNumber
from the view (2357) it works well.
So anybody has a hint how to receive the real BuildNumber
?