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)");
}
Aggregations