mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
control the presence of the abort icon based on permission.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6579 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
5edc0f17ab
commit
e2608173ca
4 files changed
+20
-6
No files matched your search
@@ -586,11 +586,8 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* People can stop a build if they can start a build.
|
||||
*/
|
||||
public void checkAbortPermission() {
|
||||
getParent().getACL().checkPermission(AbstractProject.BUILD);
|
||||
getParent().getACL().checkPermission(AbstractProject.ABORT);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -937,4 +937,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
private static final Logger LOGGER = Logger.getLogger(AbstractProject.class.getName());
|
||||
|
||||
public static final Permission BUILD = new Permission(PERMISSIONS, "Build", Permission.UPDATE);
|
||||
/**
|
||||
* Permission to abort a build. For now, let's make it the same as {@link #BUILD}
|
||||
*/
|
||||
public static final Permission ABORT = BUILD;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import javax.servlet.ServletException;
|
||||
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.acegisecurity.AccessDeniedException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -162,6 +163,18 @@ public class Executor extends Thread implements ModelObject {
|
||||
rsp.forwardToPreviousPage(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user has a permission to stop this build.
|
||||
*/
|
||||
public boolean hasStopPermission() {
|
||||
try {
|
||||
executable.checkAbortPermission();
|
||||
return true;
|
||||
} catch (AccessDeniedException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Computer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user