Skip to content

Commit

Permalink
[FIXED JENKINS-31318] Check BUILD permissions not for Jenkins but for…
Browse files Browse the repository at this point in the history
… each projects.
  • Loading branch information
ikedam committed Nov 22, 2015
1 parent 9d3e5bb commit 91d88d9
Showing 1 changed file with 16 additions and 4 deletions.
Expand Up @@ -5,12 +5,14 @@
import java.util.List;

import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerResponse;

import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.CauseAction;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.ParametersAction;

import jenkins.model.Jenkins;
Expand All @@ -20,23 +22,33 @@
*/
public class NaginatorRetryAction implements Action {

private boolean hasPermission() {
Job<?, ?> job = Stapler.getCurrentRequest().findAncestorObject(Job.class);
if (job != null) {
return job.getACL().hasPermission(Item.BUILD);
}

Jenkins j = Jenkins.getInstance();
return (j != null)?j.hasPermission(Item.BUILD):false;
}

public String getIconFileName() {
return Jenkins.getInstance().hasPermission(Item.BUILD) ?
return hasPermission() ?
"refresh.png" : null;
}

public String getDisplayName() {
return Jenkins.getInstance().hasPermission(Item.BUILD) ?
return hasPermission() ?
"Retry" : null;
}

public String getUrlName() {
return Jenkins.getInstance().hasPermission(Item.BUILD) ?
return hasPermission() ?
"retry" : null;
}

public void doIndex(StaplerResponse res, @AncestorInPath AbstractBuild build) throws IOException {
Jenkins.getInstance().checkPermission(Item.BUILD);
build.getACL().checkPermission(Item.BUILD);
NaginatorRetryAction.scheduleBuild(build, 0, NaginatorListener.calculateRetryCount(build));
res.sendRedirect2(build.getUpUrl());
}
Expand Down

0 comments on commit 91d88d9

Please sign in to comment.