use of jenkins.branch.OrganizationFolder in project blueocean-plugin by jenkinsci.
the class JobIndexingMessageEnricher method enrich.
@Override
public void enrich(@Nonnull Message message) {
if (message instanceof JobChannelMessage) {
JobChannelMessage jobChannelMessage = (JobChannelMessage) message;
Item jobChannelItem = jobChannelMessage.getJobChannelItem();
Enum indexingStatus;
Enum indexingResult;
if (jobChannelItem instanceof OrganizationFolder) {
indexingStatus = JobIndexing.EventProps.job_orgfolder_indexing_status;
indexingResult = JobIndexing.EventProps.job_orgfolder_indexing_result;
} else if (jobChannelItem instanceof MultiBranchProject) {
jobChannelMessage.set(EventProps.Job.job_ismultibranch, "true");
indexingStatus = EventProps.Job.job_multibranch_indexing_status;
indexingResult = EventProps.Job.job_multibranch_indexing_result;
} else {
// don't enrich if not org folder or multibranch
return;
}
if (message instanceof QueueTaskMessage) {
QueueTaskMessage queueTaskMessage = (QueueTaskMessage) message;
Queue.Item queueItem = queueTaskMessage.getQueueItem();
if (queueItem instanceof Queue.LeftItem) {
Queue.LeftItem leftItem = (Queue.LeftItem) queueItem;
if (leftItem.isCancelled()) {
jobChannelMessage.set(indexingStatus, "COMPLETE");
jobChannelMessage.set(indexingResult, "CANCELLED");
} else {
if (message.getEventName().equals(Events.JobChannel.job_run_queue_task_complete.name())) {
jobChannelMessage.set(indexingStatus, "COMPLETE");
Queue.Executable executable = ((Queue.LeftItem) queueItem).getExecutable();
if (executable instanceof BranchIndexing) {
BranchIndexing branchIndexing = (BranchIndexing) executable;
jobChannelMessage.set(indexingResult, branchIndexing.getResult().toString());
} else if (executable instanceof OrganizationFolder.OrganizationScan) {
OrganizationFolder.OrganizationScan orgScan = (OrganizationFolder.OrganizationScan) executable;
jobChannelMessage.set(indexingResult, orgScan.getResult().toString());
}
} else {
jobChannelMessage.set(indexingStatus, "INDEXING");
}
}
} else {
jobChannelMessage.set(indexingStatus, "INDEXING");
}
}
}
}
Aggregations