javaposse.jobdsl.dsl.helpers.MultiScmContextHelper.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of job-dsl-core Show documentation
Show all versions of job-dsl-core Show documentation
Javaposse jenkins job-dsl-core
package javaposse.jobdsl.dsl.helpers
import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.JobType
import javaposse.jobdsl.dsl.WithXmlAction
/**
multiscm {
git(String url, Closure configure) // &&
perforce(Closure configure) // &&
subverison(Closure configure)
}
*/
class MultiScmContextHelper extends AbstractContextHelper {
private JobManagement jobManagement
MultiScmContextHelper(List withXmlActions, JobType jobType, JobManagement jobManagement) {
super(withXmlActions, jobType)
this.jobManagement = jobManagement
}
/**
* Public method available directly on job {}
* @param closure
* @return
*/
def multiscm(Closure closure) {
execute(closure, new ScmContext(true, withXmlActions, jobManagement))
}
/**
...
* @param configure
*/
Closure generateWithXmlClosure(ScmContext context) {
return { Node project ->
def scm = project/scm // TODO This will create it if it doesn't exist, seems like we wouldn't need to do this, but dealing with NodeList is a pain
if (scm) {
// There can only be only one SCM, so remove if there
project.remove(scm)
}
def nodeBuilder = new NodeBuilder()
def multiscmNode = nodeBuilder.scm(class:'org.jenkinsci.plugins.multiplescms.MultiSCM')
def scmsNode = multiscmNode / scms
context.scmNodes.each {
scmsNode << it
}
// Assuming append the only child
project << multiscmNode
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy