/** * Checks the job name. */ public FormValidation doCheckJobName(@AncestorInPath Item project, @QueryParameter String value ) { final Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { return FormValidation.error("Jenkins instance is not ready"); } if (!project.hasPermission(Item.CONFIGURE) && project.hasPermission(Item.EXTENDED_READ)) { return FormValidation.ok(); } project.checkPermission(Item.CONFIGURE); if (StringUtils.isNotBlank(value)) { // JENKINS-25011: also look for jobs in folders. final AbstractProject p = ItemPathResolver.getByPath(value, project, AbstractProject.class); if (p==null) { // suggest full name so that getBuilds() can find item. AbstractProject nearest = AbstractProject.findNearest(value, project.getParent()); return FormValidation.error( nearest != null ? hudson.tasks.Messages.BuildTrigger_NoSuchProject(value, nearest.getFullName()) : hudson.plugins.promoted_builds.Messages.Shared_noSuchProject(value)); } } return FormValidation.ok(); }
/** * Checks the job name. * @param project Current project * @param value Value to be validated * @return Validation result */ public FormValidation doCheckJobName(@AncestorInPath Item project, @QueryParameter String value ) { if (!project.hasPermission(Item.CONFIGURE) && project.hasPermission(Item.EXTENDED_READ)) { return FormValidation.ok(); } project.checkPermission(Item.CONFIGURE); if (StringUtils.isNotBlank(value)) { AbstractProject p = JenkinsHelper.getInstance().getItem(value,project,AbstractProject.class); if(p==null) { AbstractProject nearest = AbstractProject.findNearest(value, project.getParent()); return FormValidation.error( nearest != null ? hudson.tasks.Messages.BuildTrigger_NoSuchProject(value, nearest.getRelativeNameFrom(project)) : Messages.Shared_noSuchProject(value)); } } return FormValidation.ok(); }
public HttpResponse doMove(StaplerRequest req, @AncestorInPath Item item, @QueryParameter String destination) throws IOException, InterruptedException { item.checkPermission(RelocationAction.RELOCATE); ItemGroup dest = null; for (ItemGroup itemGroup : listDestinations(item)) {
public HttpResponse doMove(StaplerRequest req, @AncestorInPath Item item, @QueryParameter String destination) throws IOException, InterruptedException { item.checkPermission(RelocationAction.RELOCATE); ItemGroup dest = null; for (ItemGroup itemGroup : listDestinations(item)) {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); } else { item.checkPermission(Item.CONFIGURE);
throw new AbortException("No item named " + job + " found"); item.checkPermission(Item.BUILD); if (step.getWait() && !(item instanceof Job)) {
/** * Fills in the available promotion processes. * @param defaultJob Base job * @param jobName Current name of the job specified in the form * @return List of possible project names. May be empty */ public ListBoxModel doFillProcessItems(@AncestorInPath Item defaultJob, @QueryParameter("jobName") String jobName) { if (!defaultJob.hasPermission(Item.CONFIGURE) && defaultJob.hasPermission(Item.EXTENDED_READ)) { return new ListBoxModel(); } defaultJob.checkPermission(Item.CONFIGURE); AbstractProject<?,?> j = null; if (jobName!=null) j = JenkinsHelper.getInstance().getItem(jobName,defaultJob,AbstractProject.class); ListBoxModel r = new ListBoxModel(); if (j!=null) { JobPropertyImpl pp = j.getProperty(JobPropertyImpl.class); if (pp!=null) { for (PromotionProcess proc : pp.getActiveItems()) r.add(new Option(proc.getDisplayName(),proc.getName())); } } return r; } }