Search in sources :

Example 1 with DslExtensionMethod

use of javaposse.jobdsl.plugin.DslExtensionMethod in project promoted-builds-plugin by jenkinsci.

the class PromotionsExtensionPoint method promotions.

@DslExtensionMethod(context = PropertiesContext.class)
public Object promotions(Runnable closure, DslEnvironment dslEnvironment) throws FormException, IOException {
    PromotionsContext context = new PromotionsContext(dslEnvironment);
    executeInContext(closure, context);
    dslEnvironment.put("processNames", context.names);
    JobPropertyImpl jobProperty = new JobPropertyImpl(context.names);
    Map<String, JobDslPromotionProcess> promotionProcesses = new HashMap<String, JobDslPromotionProcess>();
    for (String processName : context.names) {
        PromotionContext promotionContext = context.promotionContexts.get(processName);
        JobDslPromotionProcess jobDslPromotionProcess = new JobDslPromotionProcess();
        jobDslPromotionProcess.setName(processName);
        jobDslPromotionProcess.setIcon(promotionContext.getIcon());
        jobDslPromotionProcess.setAssignedLabel(promotionContext.getRestrict());
        jobDslPromotionProcess.setBuildSteps(promotionContext.getActions());
        jobDslPromotionProcess.setConditions(promotionContext.getConditions());
        promotionProcesses.put(processName, jobDslPromotionProcess);
    }
    dslEnvironment.put("promotionProcesses", promotionProcesses);
    return jobProperty;
}
Also used : HashMap(java.util.HashMap) JobPropertyImpl(hudson.plugins.promoted_builds.JobPropertyImpl) DslExtensionMethod(javaposse.jobdsl.plugin.DslExtensionMethod)

Aggregations

JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)1 HashMap (java.util.HashMap)1 DslExtensionMethod (javaposse.jobdsl.plugin.DslExtensionMethod)1