String name(Item i) { String n = i.getName(); if (i instanceof ItemGroup) { n += '/'; } return n; } };
public String call(Item item) { return item.getName(); } };
/** * 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; } }
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(); } } } }));
@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); } } } }
@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); } } }
while (true) { if (buf.length()>0) buf.insert(0,separationString); buf.insert(0,useDisplayName ? i.getDisplayName() : i.getName()); ItemGroup gr = i.getParent();
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>() {
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(); } }
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(); }
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 } } } } }
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.
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()); } }
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(); } } } }));
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()); }
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(); } } } }));
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; }
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; }
@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); } } } }