本文整理汇总了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);
}
示例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;
}
示例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();
}