Search in sources :

Example 1 with JenkinsJob

use of net.nemerosa.ontrack.extension.jenkins.client.JenkinsJob in project ontrack by nemerosa.

the class JenkinsJobDecorationExtension method getDecorations.

@Override
public List<Decoration<JenkinsJob>> getDecorations(ProjectEntity entity) {
    // Gets the Jenkins Job property for this entity, if any
    Property<JenkinsJobProperty> property = propertyService.getProperty(entity, JenkinsJobPropertyType.class.getName());
    if (property.isEmpty()) {
        return Collections.emptyList();
    } else {
        // Template branch? Decoration cannot be computed
        if (entity instanceof Branch && ((Branch) entity).getType() == BranchType.TEMPLATE_DEFINITION) {
            return Collections.emptyList();
        }
        // Gets a client
        // FIXME getJob does not need a full HTTP client
        JenkinsClient jenkinsClient = jenkinsClientFactory.getClient(property.getValue().getConfiguration());
        // Gets the Jenkins job
        JenkinsJob job = jenkinsClient.getJob(property.getValue().getJob());
        // Gets the decoration for the job
        return Collections.singletonList(getDecoration(job));
    }
}
Also used : JenkinsJob(net.nemerosa.ontrack.extension.jenkins.client.JenkinsJob) JenkinsClient(net.nemerosa.ontrack.extension.jenkins.client.JenkinsClient)

Aggregations

JenkinsClient (net.nemerosa.ontrack.extension.jenkins.client.JenkinsClient)1 JenkinsJob (net.nemerosa.ontrack.extension.jenkins.client.JenkinsJob)1