How do I find out additional reasons for my Jenkins build?

When I try to request an assembly using groovy, I call

myBuild.getCauses() 

I see in the Jenkins interface (assembly screen) that this assembly has two reasons: UserIdCause and UpstreamCause. However, when I interrogate the same assembly with groovy above, I get only one reason, which is UserIdCause. There must be some method of getting UpstreamCause from the assembly, or it will not be present in the user interface.

I use the Build Pipeline plugin to manually run assemblies.

+4
source share
1 answer

Here is the working groovy code (I tried in jenkins script console) use build.getAction

 job = hudson.model.Hudson.instance.getItem("demo-job") build = job.getLastBuild() // get action first def action = build.getAction(hudson.model.CauseAction.class) // get the list of causes for (cause in action.getCauses()) { println cause.getShortDescription() } // another way to find specific UpsteamCause directly cause = action.findCause(hudson.model.Cause.UpstreamCause.class) println cause.getUpstreamRun() 

See link

+1
source

All Articles