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

hudson.plugins.promoted_builds.PromotionCondition Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
package hudson.plugins.promoted_builds;

import hudson.ExtensionPoint;
import hudson.DescriptorExtensionList;
import hudson.scm.SCMDescriptor;
import hudson.scm.SCM;
import hudson.model.AbstractBuild;
import hudson.model.Describable;
import hudson.model.Hudson;
import hudson.model.AbstractProject;

import java.util.List;
import java.util.ArrayList;

/**
 * Extension point for defining a promotion criteria.
 *
 * @author Kohsuke Kawaguchi
 */
public abstract class PromotionCondition implements ExtensionPoint, Describable {
    /**
     * Checks if the promotion criteria is met.
     *
     * @param build
     *      The build for which the promotion is considered.
     * @return
     *      non-null if the promotion condition is met. This object is then recorded so that
     *      we know how a build was promoted.
     *      Null if otherwise, meaning it shouldn't be promoted.
     */
    public abstract PromotionBadge isMet(AbstractBuild build);

    public PromotionConditionDescriptor getDescriptor() {
        return (PromotionConditionDescriptor)Hudson.getInstance().getDescriptor(getClass());
    }

    /**
     * Returns all the registered {@link PromotionConditionDescriptor}s.
     */
    public static DescriptorExtensionList all() {
        return Hudson.getInstance().getDescriptorList(PromotionCondition.class);
    }

    /**
     * Returns a subset of {@link PromotionConditionDescriptor}s that applys to the given project.
     */
    public static List getApplicableTriggers(AbstractProject p) {
        List r = new ArrayList();
        for (PromotionConditionDescriptor t : all()) {
            if(t.isApplicable(p))
                r.add(t);
        }
        return r;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy