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

javaposse.jobdsl.dsl.helpers.triggers.TriggerContextHelper.groovy Maven / Gradle / Ivy

There is a newer version: 1.22-rxd-2
Show newest version
package javaposse.jobdsl.dsl.helpers.triggers

import javaposse.jobdsl.dsl.JobType
import javaposse.jobdsl.dsl.WithXmlAction
import javaposse.jobdsl.dsl.helpers.AbstractContextHelper

//import groovy.xml.XmlUtil
//import hudson.util.Secret
/**
 triggers {scm(String cronString)
 cron(String cronString)}*/
class TriggerContextHelper extends AbstractContextHelper {

    TriggerContextHelper(List withXmlActions, JobType jobType) {
        super(withXmlActions, jobType)
    }

    /**
     * Public method available on job {}* @param closure
     * @return
     */
    def triggers(Closure closure) {
        execute(closure, new TriggerContext(withXmlActions, type, []))
    }

    Closure generateWithXmlClosure(TriggerContext context) {
        return { Node project ->
            def triggersNode
            if (project.triggers.isEmpty()) {
                triggersNode = project.appendNode('triggers', [class: 'vector'])
            } else {
                triggersNode = project.triggers[0]
            }
            context.triggerNodes.each {
                triggersNode << it
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy