From 48fa591c082de5b13dbc0848fdd9218b5e27330e Mon Sep 17 00:00:00 2001 From: Jifeng Zhang Date: Thu, 15 Oct 2015 17:16:56 +0200 Subject: [PATCH 1/4] Added support of trackingSubmodules in the DSL for git submodules. Following the same implementation of recursiveSubmodules. --- .../jobdsl/dsl/helpers/ScmContext.groovy | 1 + .../jobdsl/dsl/helpers/scm/GitContext.groovy | 8 ++++ .../javaposse/jobdsl/dsl/DslSampleSpec.groovy | 3 ++ .../jobdsl/dsl/helpers/ScmContextSpec.groovy | 37 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/ScmContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/ScmContext.groovy index f7c842ae6..8cf0eebf6 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/ScmContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/ScmContext.groovy @@ -143,6 +143,7 @@ class ScmContext extends AbstractExtensibleContext { configVersion '2' disableSubmodules 'false' recursiveSubmodules gitContext.recursiveSubmodules + trackingSubmodules gitContext.trackingSubmodules doGenerateSubmoduleConfigurations 'false' authorOrCommitter 'false' clean gitContext.clean diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy index 3f345bc0f..8f9cc2c7b 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy @@ -22,6 +22,7 @@ class GitContext extends AbstractContext { boolean pruneBranches = false boolean ignoreNotifyCommit = false boolean recursiveSubmodules = false + boolean trackingSubmodules = false String localBranch String relativeTargetDir String reference = '' @@ -169,6 +170,13 @@ class GitContext extends AbstractContext { this.recursiveSubmodules = recursive } + /** + *Keep + */ + void trackingSubmodules(boolean tracking = true) { + this.trackingSubmodules = tracking + } + /** * Prunes obsolete local branches. Defaults to {@code false}. */ diff --git a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/DslSampleSpec.groovy b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/DslSampleSpec.groovy index b9394462a..79efda851 100644 --- a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/DslSampleSpec.groovy +++ b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/DslSampleSpec.groovy @@ -157,6 +157,7 @@ class DslSampleSpec extends Specification { 2 false false + false false false false @@ -300,6 +301,7 @@ mavenJob('PROJ-maven-with-template') { 2 false false + false false false false @@ -353,6 +355,7 @@ mavenJob('PROJ-maven-with-template') { 2 false false + false false false false diff --git a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/ScmContextSpec.groovy b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/ScmContextSpec.groovy index a58936886..dff5ba5d9 100644 --- a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/ScmContextSpec.groovy +++ b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/ScmContextSpec.groovy @@ -1294,6 +1294,43 @@ class ScmContextSpec extends Specification { 1 * mockJobManagement.logPluginDeprecationWarning('git', '2.2.6') } + def 'call git scm with trackingSubmodules with default true'() { + when: + context.git { + remote { + url('https://github.com/jenkinsci/job-dsl-plugin.git') + } + trackingSubmodules() + } + + then: + with(context.scmNodes[0]) { + trackingSubmodules[0].value() == true + } + 1 * mockJobManagement.requirePlugin('git') + 1 * mockJobManagement.logPluginDeprecationWarning('git', '2.2.6') + } + + def 'call git scm with trackingSubmodules with param'(boolean value) { + when: + context.git { + remote { + url('https://github.com/jenkinsci/job-dsl-plugin.git') + } + trackingSubmodules(value) + } + + then: + with(context.scmNodes[0]) { + trackingSubmodules[0].value() == value + } + 1 * mockJobManagement.requirePlugin('git') + 1 * mockJobManagement.logPluginDeprecationWarning('git', '2.2.6') + + where: + value << [true, false] + } + def 'call git scm with recursiveSubmodules with param'(boolean value) { when: context.git { From ed6095d6e1246ff75523e953c9b061f9687e90f3 Mon Sep 17 00:00:00 2001 From: Jifeng Zhang Date: Fri, 16 Oct 2015 11:49:50 +0200 Subject: [PATCH 2/4] Added missing javadoc with @since and description of the method --- build.gradle | 3 +++ .../groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 72c7c29ef..604f5792c 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,8 @@ buildscript { } } +apply plugin: 'idea' + defaultTasks 'build' // for BuildHive configure(subprojects - project(':job-dsl-api-viewer')) { @@ -16,6 +18,7 @@ configure(subprojects - project(':job-dsl-api-viewer')) { apply plugin: 'groovy' apply plugin: 'maven' // for publishing apply plugin: 'codenarc' + apply plugin: 'idea' sourceCompatibility = 1.6 targetCompatibility = 1.6 diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy index 8f9cc2c7b..26b63c9db 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitContext.groovy @@ -171,7 +171,8 @@ class GitContext extends AbstractContext { } /** - *Keep + * Update tracking submodules to tip of branch. Defaults to {@code false} + * @since 1.40 */ void trackingSubmodules(boolean tracking = true) { this.trackingSubmodules = tracking From 82dce1089836b07bd040d94a4b6c168ca2ef1041 Mon Sep 17 00:00:00 2001 From: Jifeng Zhang Date: Fri, 16 Oct 2015 11:51:20 +0200 Subject: [PATCH 3/4] Remove the accidently added idea plugin from build.gradle --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index 604f5792c..8ce818888 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,6 @@ buildscript { } } -apply plugin: 'idea' defaultTasks 'build' // for BuildHive @@ -18,7 +17,6 @@ configure(subprojects - project(':job-dsl-api-viewer')) { apply plugin: 'groovy' apply plugin: 'maven' // for publishing apply plugin: 'codenarc' - apply plugin: 'idea' sourceCompatibility = 1.6 targetCompatibility = 1.6 From 53ad5cb7c5633a6407a97fbeddf9c086c9544f31 Mon Sep 17 00:00:00 2001 From: Jifeng Zhang Date: Fri, 16 Oct 2015 11:52:58 +0200 Subject: [PATCH 4/4] Remove the extra blank line introduced --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8ce818888..72c7c29ef 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,6 @@ buildscript { } } - defaultTasks 'build' // for BuildHive configure(subprojects - project(':job-dsl-api-viewer')) {