hudson.model.Item.getName()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(118)

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

Item.getName介绍

[英]Gets the name of the item.

The name must be unique among other Items that belong to the same parent.

This name is also used for directory name, so it cannot contain any character that's not allowed on the file system.
[中]获取项的名称。
该名称在属于同一父项的其他项中必须是唯一的。
此名称还用于目录名,因此它不能包含文件系统中不允许的任何字符。

代码示例

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

String name(Item i) {
    String n = i.getName();
    if (i instanceof ItemGroup) {
      n += '/';
    }
    return n;
  }
};

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

public String call(Item item) {
    return item.getName();
  }
};

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

/**
 * True if there is no item in Jenkins that has this name
 * @param name The name to test
 * @param currentJobName The name of the job that the user is configuring
 */
boolean isNameUnique(String name, String currentJobName) {
  Item item = getItem(name);
  if(null==item) {
    // the candidate name didn't return any items so the name is unique
    return true;
  }
  else if(item.getName().equals(currentJobName)) {
    // the candidate name returned an item, but the item is the item
    // that the user is configuring so this is ok
    return true;
  }
  else {
    // the candidate name returned an item, so it is not unique
    return false;
  }
}

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

public void run(AbstractProject p) {
    for (Trigger t : (Collection<Trigger>) p.getTriggers().values()) {
      if (t instanceof SCMTrigger) {
        LOGGER.fine("synchronously triggering SCMTrigger for project " + t.job.getName());
        t.run();
      }
    }
  }
}));

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

@Override
/**
 * Called after the user has changed the project name of a job and then
 * clicked on submit.
 * @param item The item that has been renamed. The new project name is already
 * in item.getName()
 * @param oldName the old name
 * @param newName the new name
 */
public void onRenamed(Item item, String oldName, String newName) {
  // bug 5077308 - Display name field should be cleared when you rename a job.
  if(item instanceof AbstractItem) {
    AbstractItem abstractItem = (AbstractItem)item;
    if(oldName.equals(abstractItem.getDisplayName())) {
      // the user renamed the job, but the old project name which is shown as the
      // displayname if no displayname was set, has been set into the displayname field.
      // This means that the displayname was never set, so we want to set it
      // to null as it was before
      try {
        LOGGER.info(String.format("onRenamed():Setting displayname to null for item.name=%s", item.getName()));
        abstractItem.setDisplayName(null);
      }
      catch(IOException ioe) {
        LOGGER.log(Level.WARNING, String.format("onRenamed():Exception while trying to clear the displayName for Item.name:%s",
            item.getName()), ioe);
      }
    }
  }
}

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

@Override
/**
 * Called after the user has clicked OK in the New Job page when 
 * Copy existing job has been selected.
 * The fields in item will be displayed in when the config page is loaded
 * displayed.
 */
public void onCopied(Item src, Item item) {
  // bug 5056825 - Display name field should be cleared when you copy a job within the same folder.
  if(item instanceof AbstractItem && src.getParent() == item.getParent()) {
    AbstractItem dest = (AbstractItem)item;
    try {                
      dest.setDisplayName(null);
    } catch(IOException ioe) {
      LOGGER.log(Level.WARNING, String.format("onCopied():Exception while trying to clear the displayName for Item.name:%s", item.getName()), ioe);
    }
  }
}

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

while (true) {
  if (buf.length()>0) buf.insert(0,separationString);
  buf.insert(0,useDisplayName ? i.getDisplayName() : i.getName());
  ItemGroup gr = i.getParent();

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

if (oldFullName.startsWith(prefix) && oldFullName.indexOf('/', prefixS) == -1) {
  final String oldName = oldFullName.substring(prefixS);
  final String newName = rootItem.getName();
  assert newName.equals(newFullName.substring(prefixS));
  forAll(new Function<ItemListener, Void>() {

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

private StringBuilder retrieveParentUrl(Item item) {
  if (item.getParent() instanceof Item) {
    Item parent = (Item) item.getParent();
    return retrieveParentUrl(parent).append('/').append(Util.rawEncode(parent.getName()));
  } else {
    return new StringBuilder();
  }
}

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

private WebHookAction resolveAction(Item project, String restOfPath, StaplerRequest request) {
  String method = request.getMethod();
  if (method.equals("POST")) {
    return onPost(project, request);
  } else if (method.equals("GET")) {
    if (project instanceof Job<?, ?>) {
      return onGet((Job<?, ?>) project, restOfPath, request);
    } else {
      LOGGER.log(Level.FINE, "GET is not supported for this project {0}", project.getName());
      return new NoopAction();
    }
  }
  LOGGER.log(Level.FINE, "Unsupported HTTP method: {0}", method);
  return new NoopAction();
}

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

public void run() {
    for (SCMSource scmSource : ((SCMSourceOwner) project).getSCMSources()) {
      if (scmSource instanceof GitSCMSource) {
        GitSCMSource gitSCMSource = (GitSCMSource) scmSource;
        try {
          if (new URIish(gitSCMSource.getRemote()).equals(new URIish(gitSCMSource.getRemote()))) {
            if (!gitSCMSource.isIgnoreOnPushNotifications()) {
              LOGGER.log(Level.FINE, "Notify scmSourceOwner {0} about changes for {1}",
                    toArray(project.getName(), gitSCMSource.getRemote()));
              ((SCMSourceOwner) project).onSCMSourceUpdated(scmSource);
            } else {
              LOGGER.log(Level.FINE, "Ignore on push notification for scmSourceOwner {0} about changes for {1}",
                    toArray(project.getName(), gitSCMSource.getRemote()));
            }
          }
        } catch (URISyntaxException e) {
          // nothing to do
        }
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("sheet title");
int rowIndex = 0;

for (Item item : items) {
  Row row = sheet.createRow(rowIndex++);
  int columnIndex = 0;

  row.createCell(columnIndex++).setCellValue(item.getId());
  row.createCell(columnIndex++).setCellValue(item.getName());
  row.createCell(columnIndex++).setCellValue(item.getValue());
  // ...
}

workbook.write(someOutputStream); // Write the Excel result to some output.

代码示例来源:origin: stackoverflow.com

public int compare(Item a, Item b) {
 String nameA = a.getName();
 String nameB = b.getName();

 int kindA = kind(nameA);
 int kindB = kind(nameB);
 if (kindA != kindB) {
  return Integer.compare(kindA, kindB);
 } else {
  return nameA.compareToIgnoreCase(nameB);
 }
}

代码示例来源:origin: stackoverflow.com

class MyClass {

  public List<LightItem> someMethod() {
    return items.stream()
      .map(MyClass::buildLightItem)
      .collect(Collectors.toList());
  }

  private static LightItem buildLightItem(Item item) {
    return new LightItem(item.getId(), item.getName());
  }

}

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

public void run(AbstractProject p) {
    for (Trigger t : (Collection<Trigger>) p.getTriggers().values()) {
      if (t instanceof SCMTrigger) {
        LOGGER.fine("synchronously triggering SCMTrigger for project " + t.job.getName());
        t.run();
      }
    }
  }
}));

代码示例来源:origin: stackoverflow.com

final Unmarshaller u = jc.createUnmarshaller();
final File f = new File("D:\\item.xml");
final JAXBElement element = (JAXBElement) u.unmarshal(f);
final ItemList itemList = (ItemList) element.getValue();

// This will be helpful if the xml contains more elements
for (Item item : itemList.getItems()) {
  System.out.println(item.getCode());
  System.out.println(item.getName());
  System.out.println(item.getPrice());
}

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

public void run(AbstractProject p) {
    for (Trigger t : (Collection<Trigger>) p.getTriggers().values()) {
      if (t instanceof SCMTrigger) {
        LOGGER.fine("synchronously triggering SCMTrigger for project " + t.job.getName());
        t.run();
      }
    }
  }
}));

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

public Item doCreateItem(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  Item item = Hudson.getInstance().doCreateItem(req, rsp);
  if(item!=null) {
    jobNames.add(item.getName());
    owner.save();
  }
  return item;
}

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

public synchronized Item doCreateItem(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  Item item = Hudson.getInstance().doCreateItem(req, rsp);
  if (item != null) {
    jobNames.add(item.getName());
    owner.save();
  }
  return item;
}

代码示例来源:origin: org.jenkins-ci.plugins/build-pipeline-plugin

@Override
  public void onDeleted(final Item item) {
    for (final Project<?, ?> p : Jenkins.getInstance().getAllItems(Project.class)) {
      final String oldName = item.getName();
      final BuildPipelineTrigger bpTrigger = p.getPublishersList().get(BuildPipelineTrigger.class);
      if (bpTrigger != null) {
        bpTrigger.removeDownstreamTrigger(bpTrigger, p, oldName);
      }
    }
  }
}

相关文章