Search in sources :

Example 1 with BuildableItemWithBuildWrappers

use of hudson.model.BuildableItemWithBuildWrappers in project jms-messaging-plugin by jenkinsci.

the class MessageProviderMigrator method migrateCIMessageBuilders.

@Initializer(after = InitMilestone.JOB_LOADED)
public static void migrateCIMessageBuilders() {
    Jenkins instance = Jenkins.get();
    if (GlobalCIConfiguration.get().isMigrationInProgress()) {
        log.info("isMigrationInProgress - > true | Forcing GlobalCIConfiguration.save()");
        GlobalCIConfiguration.get().save();
    }
    int updatedCount = 0;
    log.info("Attempting to migrate all CIMessageBuilders, CIMessageNotifier and CIMessageSubscriberBuilders build/publish steps");
    for (BuildableItemWithBuildWrappers item : instance.getItems(BuildableItemWithBuildWrappers.class)) {
        Job<?, ?> job = (Job<?, ?>) item;
        if (job instanceof Project) {
            Project<?, ?> p = (Project<?, ?>) item.asProject();
            for (CIMessageBuilder builderObj : p.getBuildersList().getAll(CIMessageBuilder.class)) {
                if (updateCIMessageBuilder(p, builderObj)) {
                    updatedCount++;
                }
            }
            for (CIMessageNotifier notifierObj : p.getPublishersList().getAll(CIMessageNotifier.class)) {
                if (updateCIMessageNotifier(p, notifierObj)) {
                    updatedCount++;
                }
            }
            for (CIMessageSubscriberBuilder builderObj : p.getBuildersList().getAll(CIMessageSubscriberBuilder.class)) {
                if (updateCIMessageSubscriberBuilder(p, builderObj)) {
                    updatedCount++;
                }
            }
        }
        if (job instanceof MatrixProject) {
            MatrixProject p = (MatrixProject) item.asProject();
            for (CIMessageBuilder builderObj : p.getBuildersList().getAll(CIMessageBuilder.class)) {
                if (updateCIMessageBuilder(p, builderObj)) {
                    updatedCount++;
                }
            }
            for (CIMessageNotifier notifierObj : p.getPublishersList().getAll(CIMessageNotifier.class)) {
                if (updateCIMessageNotifier(p, notifierObj)) {
                    updatedCount++;
                }
            }
            for (CIMessageSubscriberBuilder builderObj : p.getBuildersList().getAll(CIMessageSubscriberBuilder.class)) {
                if (updateCIMessageSubscriberBuilder(p, builderObj)) {
                    updatedCount++;
                }
            }
        }
    }
    log.info("Updated " + updatedCount + " build/publish step(s)");
}
Also used : Jenkins(jenkins.model.Jenkins) MatrixProject(hudson.matrix.MatrixProject) Project(hudson.model.Project) AbstractProject(hudson.model.AbstractProject) CIMessageBuilder(com.redhat.jenkins.plugins.ci.CIMessageBuilder) CIMessageNotifier(com.redhat.jenkins.plugins.ci.CIMessageNotifier) BuildableItemWithBuildWrappers(hudson.model.BuildableItemWithBuildWrappers) CIMessageSubscriberBuilder(com.redhat.jenkins.plugins.ci.CIMessageSubscriberBuilder) Job(hudson.model.Job) MatrixProject(hudson.matrix.MatrixProject) Initializer(hudson.init.Initializer)

Aggregations

CIMessageBuilder (com.redhat.jenkins.plugins.ci.CIMessageBuilder)1 CIMessageNotifier (com.redhat.jenkins.plugins.ci.CIMessageNotifier)1 CIMessageSubscriberBuilder (com.redhat.jenkins.plugins.ci.CIMessageSubscriberBuilder)1 Initializer (hudson.init.Initializer)1 MatrixProject (hudson.matrix.MatrixProject)1 AbstractProject (hudson.model.AbstractProject)1 BuildableItemWithBuildWrappers (hudson.model.BuildableItemWithBuildWrappers)1 Job (hudson.model.Job)1 Project (hudson.model.Project)1 Jenkins (jenkins.model.Jenkins)1