use of jenkins.branch.MultiBranchProject 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;
Result result = branchIndexing.getResult();
if (result != null) {
jobChannelMessage.set(indexingResult, result.toString());
}
} else if (executable instanceof OrganizationFolder.OrganizationScan) {
OrganizationFolder.OrganizationScan orgScan = (OrganizationFolder.OrganizationScan) executable;
Result result = orgScan.getResult();
if (result != null) {
jobChannelMessage.set(indexingResult, result.toString());
}
}
} else {
jobChannelMessage.set(indexingStatus, "INDEXING");
}
}
} else {
jobChannelMessage.set(indexingStatus, "INDEXING");
}
}
}
}
use of jenkins.branch.MultiBranchProject in project blueocean-plugin by jenkinsci.
the class GitPipelineCreateRequestTest method createPipeline.
@Test
public void createPipeline() throws UnirestException, IOException {
User user = login("vivek", "Vivek Pandey", "vivek.pandey@gmail.com");
Map r = new PipelineBaseTest.RequestBuilder(baseUrl).status(201).jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())).crumb(crumb).post("/organizations/jenkins/pipelines/").data(MapsHelper.of("name", "pipeline1", "$class", "io.jenkins.blueocean.blueocean_git_pipeline.GitPipelineCreateRequest", "scmConfig", MapsHelper.of("id", GitScm.ID, "uri", sampleRepo.toString()))).build(Map.class);
assertNotNull(r);
assertEquals("pipeline1", r.get("name"));
MultiBranchProject mbp = (MultiBranchProject) j.getInstance().getItem("pipeline1");
GitSCMSource source = (GitSCMSource) mbp.getSCMSources().get(0);
List<SCMSourceTrait> traits = source.getTraits();
Assert.assertNotNull(SCMTrait.find(traits, BranchDiscoveryTrait.class));
Assert.assertNotNull(SCMTrait.find(traits, CleanAfterCheckoutTrait.class));
Assert.assertNotNull(SCMTrait.find(traits, CleanBeforeCheckoutTrait.class));
Assert.assertNotNull(SCMTrait.find(traits, LocalBranchTrait.class));
}
Aggregations