Skip to content
Permalink
Browse files

Merge branch 'JENKINS-43693'

  • Loading branch information...
daspilker committed Apr 30, 2017
2 parents c722b8b + 1bd2d95 commit f8b51912215c545d702b6e8c8fbe6fc129fb3130
@@ -31,6 +31,9 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
* 1.62 (unreleased)
* Show enum values for generated DSL in embedded API viewer
[#1020](https://github.com/jenkinsci/job-dsl-plugin/pull/1020)
* Enhanced support for the
[Pipeline Multibranch Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Multibranch+Plugin)
([JENKINS-43693](https://issues.jenkins-ci.org/browse/JENKINS-43693))
* Enhanced support for the [Parameterized Remote Trigger
Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Remote+Trigger+Plugin)
([JENKINS-43025](https://issues.jenkins-ci.org/browse/JENKINS-43025))
@@ -31,7 +31,7 @@ class BranchSourcesContext extends AbstractExtensibleContext {

branchSourceNodes << new NodeBuilder().'jenkins.branch.BranchSource' {
source(class: 'jenkins.plugins.git.GitSCMSource') {
id(UUID.randomUUID())
id(context.id)
remote(context.remote ?: '')
credentialsId(context.credentialsId ?: '')
includes(context.includes ?: '')
@@ -58,7 +58,7 @@ class BranchSourcesContext extends AbstractExtensibleContext {

branchSourceNodes << new NodeBuilder().'jenkins.branch.BranchSource' {
source(class: 'org.jenkinsci.plugins.github_branch_source.GitHubSCMSource') {
id(UUID.randomUUID())
id(context.id)
if (context.apiUri) {
apiUri(context.apiUri)
}
@@ -3,12 +3,22 @@ package javaposse.jobdsl.dsl.helpers.workflow
import javaposse.jobdsl.dsl.Context

class GitBranchSourceContext implements Context {
String id = UUID.randomUUID()
String remote
String credentialsId
String includes = '*'
String excludes
boolean ignoreOnPushNotifications

/**
* Specifies a unique ID for this branch source.
*
* @since 1.62
*/
void id(String id) {
this.id = id
}

/**
* Sets the Git remote repository URL.
*/
@@ -5,6 +5,7 @@ import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.RequiresPlugin

class GitHubBranchSourceContext extends AbstractContext {
String id = UUID.randomUUID()
String apiUri
String scanCredentialsId
String checkoutCredentialsId = 'SAME'
@@ -23,6 +24,15 @@ class GitHubBranchSourceContext extends AbstractContext {
super(jobManagement)
}

/**
* Specifies a unique ID for this branch source.
*
* @since 1.62
*/
void id(String id) {
this.id = id
}

/**
* Sets the GitHub API URI. Defaults to GitHub.
*/
@@ -30,7 +30,7 @@ class BranchSourcesContextsSpec extends Specification {
children().size() == 2
with(source[0]) {
children().size() == 6
id[0].value() instanceof UUID
id[0].value() instanceof String
remote[0].value().empty
credentialsId[0].value().empty
includes[0].value() == '*'
@@ -50,6 +50,7 @@ class BranchSourcesContextsSpec extends Specification {
def 'git with all options'() {
when:
context.git {
id('test')
remote('foo')
credentialsId('bar')
includes('lorem')
@@ -64,7 +65,7 @@ class BranchSourcesContextsSpec extends Specification {
children().size() == 2
with(source[0]) {
children().size() == 6
id[0].value() instanceof UUID
id[0].value() == 'test'
remote[0].value() == 'foo'
credentialsId[0].value() == 'bar'
includes[0].value() == 'lorem'
@@ -92,7 +93,7 @@ class BranchSourcesContextsSpec extends Specification {
children().size() == 2
with(source[0]) {
children().size() == 7
id[0].value() instanceof UUID
id[0].value() instanceof String
scanCredentialsId[0].value().empty
checkoutCredentialsId[0].value() == 'SAME'
repoOwner[0].value().empty
@@ -114,6 +115,7 @@ class BranchSourcesContextsSpec extends Specification {
def 'github with all options'() {
when:
context.github {
id('test')
apiUri('https://custom.url')
scanCredentialsId('scanCreds')
checkoutCredentialsId('checkoutCreds')
@@ -131,7 +133,7 @@ class BranchSourcesContextsSpec extends Specification {
children().size() == 2
with(source[0]) {
children().size() == 8
id[0].value() instanceof UUID
id[0].value() == 'test'
apiUri[0].value() == 'https://custom.url'
scanCredentialsId[0].value() == 'scanCreds'
checkoutCredentialsId[0].value() == 'checkoutCreds'
@@ -166,7 +168,7 @@ class BranchSourcesContextsSpec extends Specification {
children().size() == 2
with(source[0]) {
children().size() == 13
id[0].value() instanceof UUID
id[0].value() instanceof String
scanCredentialsId[0].value().empty
checkoutCredentialsId[0].value() == 'SAME'
repoOwner[0].value().empty
@@ -197,6 +199,7 @@ class BranchSourcesContextsSpec extends Specification {

when:
context.github {
id('test')
apiUri('https://custom.url')
scanCredentialsId('scanCreds')
checkoutCredentialsId('checkoutCreds')
@@ -220,7 +223,7 @@ class BranchSourcesContextsSpec extends Specification {
children().size() == 2
with(source[0]) {
children().size() == 14
id[0].value() instanceof UUID
id[0].value() == 'test'
apiUri[0].value() == 'https://custom.url'
scanCredentialsId[0].value() == 'scanCreds'
checkoutCredentialsId[0].value() == 'checkoutCreds'

0 comments on commit f8b5191

Please sign in to comment.
You can’t perform that action at this time.