hudson.model.Hudson.getItem()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(130)

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

Hudson.getItem介绍

[英]. Note that the look up is case-insensitive.
[中]。请注意,查找不区分大小写。

代码示例

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

/**
 * @deprecated
 *      Left only for the compatibility of URLs.
 *      Should not be invoked for any other purpose.
 */
@Deprecated
public TopLevelItem getJob(String name) {
  return getItem(name);
}

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

/**
 * Finds a {@link AbstractProject} that has the name closest to the given name.
 */
public static AbstractProject findNearest(String name) {
  List<AbstractProject> projects = Hudson.getInstance().getItems(AbstractProject.class);
  String[] names = new String[projects.size()];
  for( int i=0; i<projects.size(); i++ )
    names[i] = projects.get(i).getName();
  String nearest = EditDistance.findNearest(name, names);
  return (AbstractProject)Hudson.getInstance().getItem(nearest);
}

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

/**
 * Finds a {@link AbstractProject} that has the name closest to the given name.
 */
public static AbstractProject findNearest(String name) {
  List<AbstractProject> projects = Hudson.getInstance().getItems(AbstractProject.class);
  String[] names = new String[projects.size()];
  for( int i=0; i<projects.size(); i++ )
    names[i] = projects.get(i).getName();
  String nearest = EditDistance.findNearest(name, names);
  return (AbstractProject)Hudson.getInstance().getItem(nearest);
}

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

/**
 * @deprecated Left only for the compatibility of URLs. Should not be
 * invoked for any other purpose.
 */
public TopLevelItem getJob(String name) {
  return getItem(name);
}

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

/**
 * @deprecated
 *      Left only for the compatibility of URLs.
 *      Should not be invoked for any other purpose.
 */
public TopLevelItem getJob(String name) {
  return getItem(name);
}

代码示例来源:origin: etsy/jenkins-master-project

public AbstractProject findProject(String projectName) {
  return (AbstractProject) this.instance.getItem(projectName);
 }
}

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

/**
 * @deprecated
 *      Left only for the compatibility of URLs.
 *      Should not be invoked for any other purpose.
 */
@Deprecated
public TopLevelItem getJob(String name) {
  return getItem(name);
}

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

public final <T extends Item> T getItem(String relativeName, ItemGroup context, Class<T> type) {
  Item r = getItem(relativeName, context);
  if (type.isInstance(r)) {
    return type.cast(r);
  }
  return null;
}

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

/**
 * Gets the {@link TopLevelItem} of the given name.
 */
public TopLevelItem getItem(String name) {
  return Hudson.getInstance().getItem(name);
}

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

private synchronized void setCascadingProject(){
  if ((cascadingProjectName  != null) && StringUtils.isNotBlank(cascadingProjectName)) {
    TopLevelItem tlItem = Hudson.getInstance().getItem(cascadingProjectName);
    //Fix: 413184. Gaurd against null, the job may be externally deleted or moved
    if ( (tlItem != null) && this.getClass().isAssignableFrom( tlItem.getClass())) {
      cascadingProject = (JobT) tlItem;
    }
  }
}

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

/**
 * Gets the {@link TopLevelItem} of the given name.
 */
public TopLevelItem getItem(String name) {
  return Hudson.getInstance().getItem(name);
}

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

public static Run<?,?> fromExternalizableId(String id) {
  int hash = id.lastIndexOf('#');
  if (hash <= 0) {
    throw new IllegalArgumentException("Invalid id");
  }
  String jobName = id.substring(0, hash);
  int number = Integer.parseInt(id.substring(hash + 1));
  Job<?,?> job = (Job<?,?>) Hudson.getInstance().getItem(jobName);
  return job.getBuildByNumber(number);
}

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

public static Run<?,?> fromExternalizableId(String id) {
  int hash = id.lastIndexOf('#');
  if (hash <= 0) {
    throw new IllegalArgumentException("Invalid id");
  }
  String jobName = id.substring(0, hash);
  int number = Integer.parseInt(id.substring(hash + 1));
  Job<?,?> job = (Job<?,?>) Hudson.getInstance().getItem(jobName);
  return job.getBuildByNumber(number);
}

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

public static Run<?,?> fromExternalizableId(String id) {
  int hash = id.lastIndexOf('#');
  if (hash <= 0) {
    throw new IllegalArgumentException("Invalid id");
  }
  String jobName = id.substring(0, hash);
  int number = Integer.parseInt(id.substring(hash + 1));
  Job<?,?> job = (Job<?,?>) Hudson.getInstance().getItem(jobName);
  return job.getBuildByNumber(number);
}

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

public static BallColor getJobStatusIcon(String jobName){
  TopLevelItem job = Hudson.getInstance().getItem(jobName);
  if (job != null && job instanceof Job){
    return ((Job)job).getIconColor();
  }
  return null;
}

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

protected int run() throws Exception {
    Hudson h = Hudson.getInstance();
    h.checkPermission(Item.CREATE);

    if (h.getItem(name)!=null) {
      stderr.println("Job '"+name+"' already exists");
      return -1;
    }

    h.createProjectFromXML(name,stdin);
    return 0;
  }
}

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

/**
 * Makes sure that the given name is good as a job name.
 * @return trimmed name if valid; throws ParseException if not
 */
private String checkJobName(String name) throws Failure {
  checkGoodName(name);
  name = name.trim();
  if (getItem(name) != null) {
    throw new Failure(Messages.Hudson_JobAlreadyExists(name));
  }
  // looks good
  return name;
}

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

protected int run() throws Exception {
    Hudson h = Hudson.getInstance();
    h.checkPermission(Item.CREATE);

    if (h.getItem(name)!=null) {
      stderr.println("Job '"+name+"' already exists");
      return -1;
    }

    h.createProjectFromXML(name,stdin);
    return 0;
  }
}

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

protected int run() throws Exception {
    Hudson h = Hudson.getInstance();
    h.checkPermission(Item.CREATE);

    if (h.getItem(name)!=null) {
      stderr.println("Job '"+name+"' already exists");
      return -1;
    }

    h.createProjectFromXML(name,stdin);
    return 0;
  }
}

代码示例来源: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;
}

相关文章

Hudson类方法