Skip to content

Instantly share code, notes, and snippets.

@srz-zumix
Created March 22, 2016 13:37
Show Gist options
  • Save srz-zumix/45f3224776d73984e2b4 to your computer and use it in GitHub Desktop.
Save srz-zumix/45f3224776d73984e2b4 to your computer and use it in GitHub Desktop.
ズンドコキヨシ 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