类hudson.model.BuildableItem源码实例Demo

下面列出了怎么用hudson.model.BuildableItem的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: blueocean-plugin   文件: QueueUtil.java
/**
 * 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.");
    }
}
 
源代码2 项目: blueocean-plugin   文件: BranchImpl.java
@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;
    }
}
 
源代码3 项目: github-integration-plugin   文件: Functions.java
/**
 * 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;
    };
}
 
源代码4 项目: blueocean-plugin   文件: ScmResourceImpl.java
public ScmResourceImpl(Item item, BuildableItem branchJob, Reachable parent) {
    this.item = item;
    this.branchJob = branchJob;
    this.self = parent.getLink().rel("scm");
    checkPermission();
}
 
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;
}
 
 类所在包
 同包方法