File tree Expand file tree Collapse file tree 5 files changed +59
-2
lines changed
main/groovy/javaposse/jobdsl/dsl/helpers/triggers
test/groovy/javaposse/jobdsl/dsl/helpers/triggers Expand file tree Collapse file tree 5 files changed +59
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Have a look at the [Jenkins Job DSL Gradle example](https://github.com/sheehan/j
1818## Release Notes
1919* 1.31 (unreleased)
2020 * Added support for [ Pre-SCM Build Step Plugin] ( https://wiki.jenkins-ci.org/display/JENKINS/pre-scm-buildstep )
21+ * Added ` ignorePostCommitHooks ` option for SCM trigger
2122 * The enum argument of ` localRepository ` for the Maven job and context has changed, see [[ Migration]]
2223* 1.30 (March 08 2015)
2324 * Added support for [ Custom Tools Plugin] ( https://wiki.jenkins-ci.org/display/JENKINS/Custom+Tools+Plugin )
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ freeStyleJob(String name) { // since 1.30
8585 githubPush()
8686 pullRequest(Closure pullRequestClosure) // since 1.22
8787 scm(String cron)
88+ scm(String cron, Closure scmTriggerClosure) // since 1.31
8889 snapshotDependencies(boolean checkSnapshotDependencies)
8990 urlTrigger(String cronString = null, Closure urlTriggerClosure)
9091 }
@@ -1276,12 +1277,35 @@ cron(String cronString)
12761277Triggers job based on regular intervals.
12771278
12781279### Source Control Trigger
1280+
12791281``` groovy
1280- scm(String cronString)
1282+ job {
1283+ triggers {
1284+ scm(String cronString) {
1285+ ignorePostCommitHooks(boolean ignorePostCommitHooks = true) // since 1.31
1286+ }
1287+ }
1288+ }
12811289```
12821290
12831291Polls source control for changes at regular intervals.
12841292
1293+ ``` groovy
1294+ job {
1295+ triggers {
1296+ scm('@daily')
1297+ }
1298+ }
1299+
1300+ job {
1301+ triggers {
1302+ scm('@midnight') {
1303+ ignorePostCommitHooks()
1304+ }
1305+ }
1306+ }
1307+ ```
1308+
12851309### Github Push Notification Trigger
12861310``` groovy
12871311githubPush()
Original file line number Diff line number Diff line change 1+ package javaposse.jobdsl.dsl.helpers.triggers
2+
3+ import javaposse.jobdsl.dsl.Context
4+
5+ class ScmTriggerContext implements Context {
6+ boolean ignorePostCommitHooks
7+
8+ void ignorePostCommitHooks (boolean ignorePostCommitHooks = true ) {
9+ this . ignorePostCommitHooks = ignorePostCommitHooks
10+ }
11+ }
Original file line number Diff line number Diff line change @@ -92,12 +92,18 @@ class TriggerContext implements Context {
9292 /**
9393 * <hudson.triggers.SCMTrigger>
9494 * <spec>10 * * * *</spec>
95+ * <ignorePostCommitHooks>false</ignorePostCommitHooks>
9596 * </hudson.triggers.SCMTrigger>
9697 */
97- void scm (String cronString ) {
98+ void scm (String cronString , @DslContext ( ScmTriggerContext ) Closure scmTriggerClosure = null ) {
9899 Preconditions . checkNotNull(cronString)
100+
101+ ScmTriggerContext scmTriggerContext = new ScmTriggerContext ()
102+ ContextHelper . executeInContext(scmTriggerClosure, scmTriggerContext)
103+
99104 triggerNodes << new NodeBuilder (). ' hudson.triggers.SCMTrigger' {
100105 spec cronString
106+ ignorePostCommitHooks scmTriggerContext. ignorePostCommitHooks
101107 }
102108 }
103109
Original file line number Diff line number Diff line change @@ -283,6 +283,21 @@ class TriggerContextSpec extends Specification {
283283 timerTrigger. spec[0 ]. value() == ' */5 * * * *'
284284 }
285285
286+ def ' call scm trigger with closure' () {
287+ when :
288+ context. scm(' */5 * * * *' ) {
289+ ignorePostCommitHooks()
290+ }
291+
292+ then :
293+ with(context. triggerNodes[0 ]) {
294+ name() == ' hudson.triggers.SCMTrigger'
295+ children(). size() == 2
296+ spec[0 ]. value() == ' */5 * * * *'
297+ ignorePostCommitHooks[0 ]. value() == true
298+ }
299+ }
300+
286301 def ' call pull request trigger with no args' () {
287302 when :
288303 context. pullRequest()
You can’t perform that action at this time.
0 commit comments