From 247de1e9568c5378eaa776b6c126cf4661c4a487 Mon Sep 17 00:00:00 2001 From: Reinhard Naegele Date: Thu, 18 Feb 2016 09:40:23 +0100 Subject: [PATCH] Add Gitiles as repo browser --- .../dsl/helpers/scm/GitBrowserContext.groovy | 11 +++++++++++ .../jobdsl/dsl/helpers/ScmContextSpec.groovy | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitBrowserContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitBrowserContext.groovy index 45e0f7783..bedda6666 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitBrowserContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/GitBrowserContext.groovy @@ -37,4 +37,15 @@ class GitBrowserContext implements Context { delegate.version(version) } } + + /** + * Use Gitiles as repository browser. + * + * @since 1.44 + */ + void gitiles(String url) { + browser = NodeBuilder.newInstance().browser(class: 'hudson.plugins.git.browser.Gitiles') { + delegate.url(url) + } + } } 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 bb8b44475..58365eb3b 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 @@ -852,6 +852,25 @@ class ScmContextSpec extends Specification { 1 * mockJobManagement.requireMinimumPluginVersion('git', '2.2.6') } + def 'call git scm with gitilesBrowser'() { + when: + context.git { + remote { + url('https://github.com/jenkinsci/job-dsl-plugin.git') + } + browser { + gitiles('http://gitiles') + } + } + + then: + context.scmNodes[0] != null + context.scmNodes[0].browser.size() == 1 + context.scmNodes[0].browser[0].attribute('class') == 'hudson.plugins.git.browser.Gitiles' + context.scmNodes[0].browser[0].'url'[0].value() == 'http://gitiles' + 1 * mockJobManagement.requireMinimumPluginVersion('git', '2.2.6') + } + def 'call git scm with ignoreNotifyCommit'() { when: context.git {