Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ズンドコキヨシ for Jenkins
import hudson.model.Cause.UpstreamCause
static checkZUN(manager, cause, count)
{
def causes = cause.getUpstreamCauses()
def name = cause.getUpstreamProject()
manager.listener.logger.println name
if( name == "ZUN" ) {
count += 1
if( count == 4 ) {
return true
}
} else {
return false
}
cause = null
causes.each {
if( it instanceof UpstreamCause ) {
cause = it
return
}
}
return checkZUN(manager, cause, count)
}
static setNext(manager)
{
def r = Math.floor( Math.random() * 2 ) as int
manager.listener.logger.println r
if( r ) {
manager.buildUnstable()
} else {
manager.buildFailure()
}
}
static check(manager)
{
def name = manager.build.getProject().getName()
manager.listener.logger.println name
if( name == "DOKO" ) {
def cause = manager.build.getCause(UpstreamCause.class)
if( checkZUN(manager, cause, 0) ) {
return true
}
}
setNext(manager)
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment