public boolean hasAbortPermission() { return hasPermission(CANCEL); }
@Exported(name="upstreamProjects") @Restricted(DoNotUse.class) // only for exporting public List<AbstractProject> getUpstreamProjectsForApi() { List<AbstractProject> r = new ArrayList<>(); for (AbstractProject p : getUpstreamProjects()) { if (p.hasPermission(Item.READ)) { r.add(p); } } return r; }
@Exported(name="downstreamProjects") @Restricted(DoNotUse.class) // only for exporting public List<AbstractProject> getDownstreamProjectsForApi() { List<AbstractProject> r = new ArrayList<>(); for (AbstractProject p : getDownstreamProjects()) { if (p.hasPermission(Item.READ)) { r.add(p); } } return r; }
if(!project.hasPermission(Item.CONFIGURE)) return FormValidation.ok();
@Override public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener, List<Action> actions) { AbstractProject downstream = getDownstreamProject(); if (Jenkins.getInstance().getItemByFullName(downstream.getFullName()) != downstream) { // this checks Item.READ also on parent folders LOGGER.log(Level.WARNING, "Running as {0} cannot even see {1} for trigger from {2}", new Object[] {Jenkins.getAuthentication().getName(), downstream, getUpstreamProject()}); return false; // do not even issue a warning to build log } if (!downstream.hasPermission(Item.BUILD)) { listener.getLogger().println(Messages.BuildTrigger_you_have_no_permission_to_build_(ModelHyperlinkNote.encodeTo(downstream))); return false; } return build.getResult().isBetterOrEqualTo(threshold); } });
@Override public String getWhyKeepLog() { // if any of the downstream project is configured with 'keep dependency component', // we need to keep this log OUTER: for (AbstractProject<?,?> p : getParent().getDownstreamProjects()) { if (!p.isKeepDependencies()) continue; AbstractBuild<?,?> fb = p.getFirstBuild(); if (fb==null) continue; // no active record // is there any active build that depends on us? for (int i : getDownstreamRelationship(p).listNumbersReverse()) { // TODO: this is essentially a "find intersection between two sparse sequences" // and we should be able to do much better. if (i<fb.getNumber()) continue OUTER; // all the other records are younger than the first record, so pointless to search. AbstractBuild<?,?> b = p.getBuildByNumber(i); if (b!=null) return Messages.AbstractBuild_KeptBecause(p.hasPermission(Item.READ) ? b.toString() : "?"); } } return super.getWhyKeepLog(); }
public String getIconFileName() { if (project.hasPermission(ArtifactoryPlugin.RELEASE)) { return "/plugin/artifactory/images/artifactory-release.png"; } // return null to hide the action (doSubmit will also perform permission check if someone tries direct link) return null; } }
@Override public boolean hasBuildPermission(BuildPipelineView owner) { final AbstractProject<?, ?> job = getFirstJob(owner); return job != null && job.hasPermission(Item.BUILD); }
private String checkPermission(Sender sender, AbstractProject<?, ?> project) { if (!project.hasPermission(Item.BUILD)) { return sender.getNickname() + ": you're not allowed to build job " + project.getDisplayName() + "!"; } return null; }
@Exported(name="downstreamProjects") @Restricted(DoNotUse.class) // only for exporting public List<AbstractProject> getDownstreamProjectsForApi() { List<AbstractProject> r = new ArrayList<>(); for (AbstractProject p : getDownstreamProjects()) { if (p.hasPermission(Item.READ)) { r.add(p); } } return r; }
@Exported(name="upstreamProjects") @Restricted(DoNotUse.class) // only for exporting public List<AbstractProject> getUpstreamProjectsForApi() { List<AbstractProject> r = new ArrayList<>(); for (AbstractProject p : getUpstreamProjects()) { if (p.hasPermission(Item.READ)) { r.add(p); } } return r; }
@CheckForNull public static ManualStep resolveManualStep(AbstractProject project) { if (isManualTrigger(project)) { return new ManualStep(project.getName(), null, false, project.hasPermission(Item.BUILD), null); } else { return null; } }
@Override protected SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder sib = super.makeSearchIndex(); if (isBuildable() && hasPermission(Hudson.ADMINISTER)) { sib.add("build", "build"); } return sib; }
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(); }
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(); }
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(); }
@Override protected SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder sib = super.makeSearchIndex(); if (isBuildable() && hasPermission(Hudson.ADMINISTER)) { sib.add("build", "build"); } return sib; }
@Override protected SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder sib = super.makeSearchIndex(); if(isBuildable() && hasPermission(Hudson.ADMINISTER)) sib.add("build","build"); return sib; }
@Override protected SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder sib = super.makeSearchIndex(); if(isBuildable() && hasPermission(Hudson.ADMINISTER)) sib.add("build","build"); return sib; }
/** * Method for checking,whether the rebuild functionality would be available * for build. * * @return boolean */ public boolean isRebuildAvailable() { return getProject() != null && getProject().hasPermission(AbstractProject.BUILD) && getProject().isBuildable() && !(getProject().isDisabled()) && !isMatrixRun(); }