hudson.model.BuildableItem Java Examples
The following examples show how to use
hudson.model.BuildableItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueueUtil.java From blueocean-plugin with MIT License | 6 votes |
/** * This function gets gets a list of all queued items if the job is a buildable item. * * Note the estimated build number calculation is a guess - job types need not return * sequential build numbers. * * @return List of items newest first */ public static List<BlueQueueItem> getQueuedItems(BlueOrganization organization, Job job) { BluePipeline pipeline = (BluePipeline) BluePipelineFactory.resolve(job); if(job instanceof BuildableItem && pipeline != null) { BuildableItem task = (BuildableItem)job; List<hudson.model.Queue.Item> items = Jenkins.getInstance().getQueue().getItems(task); List<BlueQueueItem> items2 = Lists.newArrayList(); for (int i = 0; i < items.size(); i++) { Link self = pipeline.getLink().rel("queue").rel(Long.toString(items.get(i).getId())); QueueItemImpl queueItem = new QueueItemImpl( organization, items.get(i), pipeline, (items.size() == 1 ? job.getNextBuildNumber() : job.getNextBuildNumber() + i), self, pipeline.getLink()); items2.add(0, queueItem); } return items2; } else { throw new ServiceException.UnexpectedErrorException("This pipeline is not buildable and therefore does not have a queue."); } }
Example #2
Source File: BranchImpl.java From blueocean-plugin with MIT License | 5 votes |
@Navigable @Override public BluePipelineScm getScm() { if(job instanceof WorkflowJob && job.getParent() instanceof ComputedFolder) { return new ScmResourceImpl((ComputedFolder) job.getParent(), (BuildableItem) job,this); }else{ return null; } }
Example #3
Source File: Functions.java From github-integration-plugin with MIT License | 5 votes |
/** * Can be useful to ignore disabled jobs on reregistering hooks * * @return predicate with true on apply if item is buildable */ public static <ITEM extends Item> Predicate<ITEM> isBuildable() { return item -> { if (item instanceof Job) { return ((Job) item).isBuildable(); } else if (item instanceof ComputedFolder) { return ((ComputedFolder) item).isBuildable(); } return item instanceof BuildableItem; }; }
Example #4
Source File: ScmResourceImpl.java From blueocean-plugin with MIT License | 4 votes |
public ScmResourceImpl(Item item, BuildableItem branchJob, Reachable parent) { this.item = item; this.branchJob = branchJob; this.self = parent.getLink().rel("scm"); checkPermission(); }
Example #5
Source File: GogsPayloadProcessor.java From gogs-webhook-plugin with MIT License | 4 votes |
public GogsResults triggerJobs(String jobName, String deliveryID) { SecurityContext saveCtx = ACL.impersonate(ACL.SYSTEM); GogsResults result = new GogsResults(); try { BuildableItem project = GogsUtils.find(jobName, BuildableItem.class); if (project != null) { GogsTrigger gTrigger = null; Cause cause = new GogsCause(deliveryID); if (project instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) project; for (Trigger trigger : pJob.getTriggers().values()) { if (trigger instanceof GogsTrigger) { gTrigger = (GogsTrigger) trigger; break; } } } if (gTrigger != null) { SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(project); GogsPayload gogsPayload = new GogsPayload(this.payload); if (item != null) { item.scheduleBuild2(0, gogsPayload); } } else { project.scheduleBuild(0, cause); } result.setMessage(String.format("Job '%s' is executed", jobName)); } else { String msg = String.format("Job '%s' is not defined in Jenkins", jobName); result.setStatus(404, msg); LOGGER.warning(msg); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOGGER.severe(sw.toString()); } finally { SecurityContextHolder.setContext(saveCtx); } return result; }