All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javaposse.jobdsl.dsl.helpers.MultiScmContextHelper.groovy Maven / Gradle / Ivy

There is a newer version: 1.22-rxd-2
Show newest version
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