Skip to content

Instantly share code, notes, and snippets.

@ogavrisevs
Created November 8, 2013 16:35
Show Gist options
  • Save ogavrisevs/7373751 to your computer and use it in GitHub Desktop.
Save ogavrisevs/7373751 to your computer and use it in GitHub Desktop.
Java couses example
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def printCouse(cause) {
println("cause ========> : "+ cause )
println("cause.class ========> : "+ cause.class )
if (cause instanceof Cause.UserIdCause){
userCause = ( Cause.UserIdCause) cause
println("userCause.getUserName() ========>"+ userCause.getUserName() )
}
if (cause instanceof Cause.UpstreamCause){
upstreamCause =( Cause.UpstreamCause) cause
for( upCause in upstreamCause.getUpstreamCauses()) {
printCouse(upCause)
}
}
}
for (job in Hudson.instance.items) {
def action = job.getAction(CauseAction.class)
if (action != null) {
println("action.getCauses() ========> "+ action.getCauses())
println("action.class ========> "+ action.class)
for (cause in action.getCauses() ){
printCouse(cause)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment