Skip to content
Permalink
Browse files
[JENKINS-31879] Added support for DOS Trigger plugin
  • Loading branch information
v1v committed Dec 3, 2015
1 parent 0abcdd9 commit ffa02fe38bc590fed676875bfd5ffa145fedb467
@@ -0,0 +1,7 @@
job('example') {
triggers {
dos('@daily') {
triggerScript('set CAUSE=Build successfully triggered by dostrigger.')
}
}
}
@@ -0,0 +1,15 @@
package javaposse.jobdsl.dsl.helpers.triggers

import javaposse.jobdsl.dsl.Context

class DosTriggerContext implements Context {
String triggerScript

/**
* It sets the script that will be executed periodically which indicates that a build should be started
* when the script sets the CAUSE variable to something.
*/
void triggerScript(String triggerScript) {
this.triggerScript = triggerScript
}
}
@@ -327,4 +327,23 @@ class TriggerContext extends AbstractExtensibleContext {
spec()
}
}

/**
* Trigger a build with a DOS script..
*
* @since 1.41
*/
@RequiresPlugin(id = 'dos-trigger', minimumVersion = '1.23')
void dos(String cronString, @DslContext(DosTriggerContext) Closure closure) {
Preconditions.checkNotNull(cronString, 'cronString must be specified')

DosTriggerContext context = new DosTriggerContext()
ContextHelper.executeInContext(closure, context)

triggerNodes << new NodeBuilder().'org.jenkinsci.plugins.dostrigger.DosTrigger' {
spec(cronString)
script(context.triggerScript)
nextBuildNum(0)
}
}
}
@@ -800,4 +800,23 @@ class TriggerContextSpec extends Specification {
}
1 * mockJobManagement.requireMinimumPluginVersion('bitbucket', '1.1.2')
}

def 'call dos trigger methods'() {
when:
context.dos('*/10 * * * *') {
triggerScript('set CAUSE=Build successfully triggered by dostrigger.')
}

then:
context.triggerNodes.size() == 1
with(context.triggerNodes[0]) {
name() == 'org.jenkinsci.plugins.dostrigger.DosTrigger'
children().size() == 3
spec[0].value() == '*/10 * * * *'
script[0].value() == 'set CAUSE=Build successfully triggered by dostrigger.'
nextBuildNum[0].value() == 0
}

1 * mockJobManagement.requireMinimumPluginVersion('dos-trigger', '1.23')
}
}

0 comments on commit ffa02fe

Please sign in to comment.