当前位置: 首页>>代码示例>>Java>>正文


Java Jenkins.getItem方法代码示例

本文整理汇总了Java中jenkins.model.Jenkins.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java Jenkins.getItem方法的具体用法?Java Jenkins.getItem怎么用?Java Jenkins.getItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jenkins.model.Jenkins的用法示例。


在下文中一共展示了Jenkins.getItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import jenkins.model.Jenkins; //导入方法依赖的package包/类
@Override
public RunWrapper run() throws Exception {

    String jobName = step.getJob();
    if (jobName == null) {
        throw new AbortException(Messages.SelectRunStep_MissingJobParameter());
    }

    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        throw new IllegalStateException("Jenkins has not been started, or was already shut down");
    }
    Job<?, ?> upstreamJob = jenkins.getItem(jobName, run.getParent(), Job.class);
    if (upstreamJob == null) {
        throw new AbortException(Messages.SelectRunStep_MissingJob(jobName));
    }

    RunSelector selector = step.getSelector();
    if (selector == null) {
        listener.getLogger().println(Messages.SelectRunStep_MissingRunSelector(DEFAULT_RUN_SELECTOR.getDisplayName()));
        selector = DEFAULT_RUN_SELECTOR;
    }

    RunFilter filter = step.getFilter();
    if (filter == null) {
        listener.getLogger().println(Messages.SelectRunStep_MissingRunFilter());
        filter = DEFAULT_RUN_FILTER;
    }

    RunSelectorContext context = new RunSelectorContext(jenkins, run, listener, filter);
    context.setVerbose(step.isVerbose());

    Run<?, ?> upstreamRun = selector.select(upstreamJob, context);
    if (upstreamRun == null) {
        throw new AbortException(Messages.SelectRunStep_MissingRun(jobName, selector.getDisplayName(), filter.getDisplayName()));
    }

    return new RunWrapper(upstreamRun, false);
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:40,代码来源:SelectRunExecution.java

示例2: doFillIdItems

import jenkins.model.Jenkins; //导入方法依赖的package包/类
public ComboBoxModel doFillIdItems(@AncestorInPath Job<?, ?> copyingJob, @RelativePath("..") @QueryParameter("projectName") String projectName) {
    Job<?, ?> j = null;
    Jenkins jenkins = Jenkins.getInstance();
    if (projectName != null && jenkins != null) {
        j = jenkins.getItem(projectName, copyingJob, Job.class);
    }
    ComboBoxModel r = new ComboBoxModel();
    for (Permalink p : j != null ? j.getPermalinks() : Permalink.BUILTIN) {
        r.add(p.getId());
    }
    return r;
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:13,代码来源:PermalinkRunSelector.java

示例3: doCheckUpstreamProjectName

import jenkins.model.Jenkins; //导入方法依赖的package包/类
/**
 * Validates a form input to "Upstream Project Name"
 *
 * @param project Ancestor project.
 * @param upstreamProjectName Upstream project name.
 * @return the form validation result.
 */
public FormValidation doCheckUpstreamProjectName(
        @AncestorInPath Job<?,?> project,
        @QueryParameter String upstreamProjectName
) {
    upstreamProjectName = StringUtils.trim(upstreamProjectName);
    if (StringUtils.isBlank(upstreamProjectName)) {
        return FormValidation.error(Messages.DownstreamRunFilter_UpstreamProjectName_Required());
    }
    
    if (containsVariable(upstreamProjectName)) {
        return FormValidation.ok();
    }
    
    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        // Jenkins is unavailable and validation is useless.
        return FormValidation.ok();
    }

    if (project == null) {
        // Context is unknown and validation is useless.
        return FormValidation.ok(org.jenkinsci.plugins.runselector.Messages.RunSelector_AncestorIsNull());
    }

    Job<?,?> upstreamRoot = (project instanceof AbstractProject)
            ? ((AbstractProject<?,?>) project).getRootProject()
            : project;

    Job<?,?> upstreamProject = jenkins.getItem(
            upstreamProjectName, upstreamRoot, Job.class
    );

    if (upstreamProject == null || !upstreamProject.hasPermission(Item.READ)) {
        return FormValidation.error(Messages.DownstreamRunFilter_UpstreamProjectName_NotFound());
    }

    if (!(upstreamProject instanceof AbstractProject)) {
        return FormValidation.error(
            Messages.DownstreamRunFilter_UpstreamProjectName_NotAbstractProject(
                upstreamProject.getClass().getName()
            )
        );
    }

    return FormValidation.ok();
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:54,代码来源:DownstreamRunFilter.java


注:本文中的jenkins.model.Jenkins.getItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。