Search in sources :

Example 6 with OrganizationFolder

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");
            }
        }
    }
}
Also used : JobChannelMessage(org.jenkinsci.plugins.pubsub.JobChannelMessage) OrganizationFolder(jenkins.branch.OrganizationFolder) BranchIndexing(jenkins.branch.MultiBranchProject.BranchIndexing) Item(hudson.model.Item) QueueTaskMessage(org.jenkinsci.plugins.pubsub.QueueTaskMessage) MultiBranchProject(jenkins.branch.MultiBranchProject) Queue(hudson.model.Queue)

Aggregations

OrganizationFolder (jenkins.branch.OrganizationFolder)6 User (hudson.model.User)3 GitHubSCMNavigator (org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator)3 StandardCredentials (com.cloudbees.plugins.credentials.common.StandardCredentials)2 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)2 Domain (com.cloudbees.plugins.credentials.domains.Domain)2 Cause (hudson.model.Cause)2 Item (hudson.model.Item)2 TopLevelItem (hudson.model.TopLevelItem)2 PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)2 BlueOceanDomainRequirement (io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanDomainRequirement)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MultiBranchProject (jenkins.branch.MultiBranchProject)2 Test (org.junit.Test)2 AbstractFolderProperty (com.cloudbees.hudson.plugins.folder.AbstractFolderProperty)1 CredentialsStore (com.cloudbees.plugins.credentials.CredentialsStore)1 DomainSpecification (com.cloudbees.plugins.credentials.domains.DomainSpecification)1 UsernamePasswordCredentialsImpl (com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl)1 ImmutableMap (com.google.common.collect.ImmutableMap)1