hudson.model.AbstractProject.findNearest()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中hudson.model.AbstractProject.findNearest()方法的一些代码示例,展示了AbstractProject.findNearest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractProject.findNearest()方法的具体详情如下:
包路径:hudson.model.AbstractProject
类名称:AbstractProject
方法名:findNearest

AbstractProject.findNearest介绍

[英]Finds a AbstractProject that has the name closest to the given name.
[中]查找名称与给定名称最接近的抽象项目。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Finds a {@link AbstractProject} that has the name closest to the given name.
 * @see Items#findNearest
 */
public static @CheckForNull AbstractProject findNearest(String name) {
  return findNearest(name,Jenkins.getInstance());
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Used for CLI binding.
 */
@CLIResolver
public static AbstractProject resolveForCLI(
    @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
  AbstractProject item = Jenkins.getInstance().getItemByFullName(name, AbstractProject.class);
  if (item==null) {
    AbstractProject project = AbstractProject.findNearest(name);
    throw new CmdLineException(null, project == null ? Messages.AbstractItem_NoSuchJobExistsWithoutSuggestion(name)
        : Messages.AbstractItem_NoSuchJobExists(name, project.getFullName()));
  }
  return item;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Obtains the {@link WorkspaceSnapshot} object that this {@link SCM} points to,
 * or throws {@link hudson.fsp.WorkspaceSnapshotSCM.ResolvedFailedException} upon failing.
 *
 * @return never null.
 */
public Snapshot resolve() throws ResolvedFailedException {
  Jenkins h = Jenkins.getInstance();
  AbstractProject<?,?> job = h.getItemByFullName(jobName, AbstractProject.class);
  if(job==null) {
    if(h.getItemByFullName(jobName)==null) {
      AbstractProject nearest = AbstractProject.findNearest(jobName);
      throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchJob(jobName,nearest.getFullName()));
    } else
      throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_IncorrectJobType(jobName));
  }
  PermalinkList permalinks = job.getPermalinks();
  Permalink p = permalinks.get(permalink);
  if(p==null)
    throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchPermalink(permalink,jobName));
  AbstractBuild<?,?> b = (AbstractBuild<?,?>)p.resolve(job);
  if(b==null)
    throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoBuild(permalink,jobName));
  WorkspaceSnapshot snapshot = b.getAction(WorkspaceSnapshot.class);
  if(snapshot==null)
    throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoWorkspace(jobName,permalink));
  return new Snapshot(snapshot,b);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Finds a {@link AbstractProject} that has the name closest to the given name.
 * @see Items#findNearest
 */
public static @CheckForNull AbstractProject findNearest(String name) {
  return findNearest(name,Jenkins.getInstance());
}

代码示例来源:origin: hudson/hudson-2.x

public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) {
  // Require CONFIGURE permission on this project
  if(!project.hasPermission(Item.CONFIGURE))  return FormValidation.ok();
  for (String name : Util.tokenize(fixNull(value), ",")) {
    name = name.trim();
    if(Hudson.getInstance().getItemByFullName(name)==null)
      return FormValidation.error(hudson.tasks.Messages.BuildTrigger_NoSuchProject(name,AbstractProject.findNearest(name).getName()));
  }
  
  return FormValidation.ok();
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) {
  // Require CONFIGURE permission on this project
  if(!project.hasPermission(Item.CONFIGURE))  return FormValidation.ok();
  for (String name : Util.tokenize(fixNull(value), ",")) {
    name = name.trim();
    if(Hudson.getInstance().getItemByFullName(name)==null)
      return FormValidation.error(hudson.tasks.Messages.BuildTrigger_NoSuchProject(name,AbstractProject.findNearest(name).getName()));
  }
  
  return FormValidation.ok();
}

代码示例来源:origin: jenkinsci/junit-plugin

public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) {
  // Require CONFIGURE permission on this project
  if(!project.hasPermission(Item.CONFIGURE))  return FormValidation.ok();
  for (String name : Util.tokenize(fixNull(value), ",")) {
    name = name.trim();
    if (Helper.getActiveInstance().getItem(name,project) == null) {
      final AbstractProject<?,?> nearest = AbstractProject.findNearest(name);
      return FormValidation.error(Messages.BuildTrigger_NoSuchProject(name, nearest != null ? nearest.getName() : null));
    }
  }
  
  return FormValidation.ok();
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) {
  // Require CONFIGURE permission on this project
  if(!project.hasPermission(Item.CONFIGURE))  return FormValidation.ok();
  for (String name : Util.tokenize(fixNull(value), ",")) {
    name = name.trim();
    if(Hudson.getInstance().getItemByFullName(name)==null)
      return FormValidation.error(hudson.tasks.Messages.BuildTrigger_NoSuchProject(name,AbstractProject.findNearest(name).getName()));
  }
  
  return FormValidation.ok();
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  TopLevelItem s = h.getItem(src);
  if (s==null)
    throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant "+ AbstractProject.findNearest(src)+"?");
  setter.addValue(s);
  return 1;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  AbstractProject s = h.getItemByFullName(src,AbstractProject.class);
  if (s==null)
    throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant "+ AbstractProject.findNearest(src)+"?");
  setter.addValue(s);
  return 1;
}

代码示例来源:origin: hudson/hudson-2.x

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  AbstractProject s = h.getItemByFullName(src,AbstractProject.class);
  if (s==null)
    throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant "+ AbstractProject.findNearest(src)+"?");
  setter.addValue(s);
  return 1;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  AbstractProject s = h.getItemByFullName(src,AbstractProject.class);
  if (s==null)
    throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant "+ AbstractProject.findNearest(src)+"?");
  setter.addValue(s);
  return 1;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  TopLevelItem s = h.getItem(src);
  if (s==null)
    throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant "+ AbstractProject.findNearest(src)+"?");
  setter.addValue(s);
  return 1;
}

代码示例来源:origin: hudson/hudson-2.x

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  TopLevelItem s = h.getItem(src);
  if (s==null)
    throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant "+ AbstractProject.findNearest(src)+"?");
  setter.addValue(s);
  return 1;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  if (isAuthenticated()) {
    AbstractProject s = h.getItemByFullName(src, AbstractProject.class);
    if (s == null) {
      throw new CmdLineException(owner, "No such job '" + src + "' perhaps you meant " + AbstractProject.findNearest(src) + "?");
    }
    setter.addValue(s);
  }
  return 1;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

@Override
public int parseArguments(Parameters params) throws CmdLineException {
  Hudson h = Hudson.getInstance();
  String src = params.getParameter(0);
  if (isAuthenticated()) {
    TopLevelItem s = h.getItem(src);
    if (s == null) {
      throw new CmdLineException(owner, "No such job '" + src + "' perhaps you meant " + AbstractProject.findNearest(src) + "?");
    }
    setter.addValue(s);
  }
  return 1;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
   * Used for CLI binding.
   */
  @CLIResolver
  public static AbstractProject resolveForCLI(
      @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
    AbstractProject item = Hudson.getInstance().getItemByFullName(name, AbstractProject.class);
    if (item==null)
      throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
    return item;
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
   * Used for CLI binding.
   */
  @CLIResolver
  public static AbstractItem resolveForCLI(
      @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
    AbstractItem item = Hudson.getInstance().getItemByFullName(name, AbstractItem.class);
    if (item==null)
      throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
    return item;
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
   * Used for CLI binding.
   */
  @CLIResolver
  public static AbstractProject resolveForCLI(
      @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
    AbstractProject item = Hudson.getInstance().getItemByFullName(name, AbstractProject.class);
    if (item==null)
      throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
    return item;
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
   * Used for CLI binding.
   */
  @CLIResolver
  public static AbstractItem resolveForCLI(
      @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
    AbstractItem item = Hudson.getInstance().getItemByFullName(name, AbstractItem.class);
    if (item==null)
      throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
    return item;
  }
}

相关文章

微信公众号

最新文章

更多

AbstractProject类方法