Search in sources :

Example 1 with BuildCondition

use of org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition in project blueocean-plugin by jenkinsci.

the class PipelineMetadataService method doBuildConditions.

/**
 * Function to return the names of all build conditions present in the system when accessed through the REST API
 */
@GET
@TreeResponse
public ExportedBuildCondition[] doBuildConditions() {
    List<ExportedBuildCondition> exported = new ArrayList<>();
    for (BuildCondition c : BuildCondition.all()) {
        exported.add(new ExportedBuildCondition(symbolForObject(c), c.getDescription()));
    }
    Collections.sort(exported, new Comparator<ExportedBuildCondition>() {

        @Override
        public int compare(ExportedBuildCondition o1, ExportedBuildCondition o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    return exported.toArray(new ExportedBuildCondition[exported.size()]);
}
Also used : ArrayList(java.util.ArrayList) BuildCondition(org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition) TreeResponse(io.jenkins.blueocean.commons.stapler.TreeResponse) GET(org.kohsuke.stapler.verb.GET)

Aggregations

TreeResponse (io.jenkins.blueocean.commons.stapler.TreeResponse)1 ArrayList (java.util.ArrayList)1 BuildCondition (org.jenkinsci.plugins.pipeline.modeldefinition.model.BuildCondition)1 GET (org.kohsuke.stapler.verb.GET)1