Skip to content
Permalink
Browse files

[JENKINS-9694] bot permissions didn't apply for build command

  • Loading branch information...
kutzi
kutzi committed May 15, 2011
1 parent e886062 commit b43fe93ee8970d665e44fc64318e791ffd3b6f58
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/main/java/hudson/plugins/im/bot/BuildCommand.java
@@ -7,12 +7,14 @@
import hudson.model.AbstractProject;
import hudson.model.BooleanParameterValue;
import hudson.model.Cause;
import hudson.model.Item;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.Queue;
import hudson.model.StringParameterValue;
import hudson.plugins.im.IMCause;
import hudson.plugins.im.Sender;
import hudson.security.Permission;

import java.util.ArrayList;
import java.util.Arrays;
@@ -62,6 +64,11 @@ public String getReply(Bot bot, Sender sender, String args[]) {
AbstractProject<?, ?> project = getJobProvider().getJobByName(jobName);
if (project != null) {

String checkPermission = checkPermission(sender, project);
if (checkPermission != null) {
return checkPermission;
}

String msg = "";
if (project.isInQueue()) {
Queue.Item queueItem = project.getQueueItem();
@@ -147,12 +154,20 @@ public String getReply(Bot bot, Sender sender, String args[]) {
}
}

private String giveSyntax(String sender, String cmd) {
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;
}

private String giveSyntax(String sender, String cmd) {
return sender + ": syntax is: '" + cmd + SYNTAX + "'";
}

public String getHelp() {
return HELP;
}


}

0 comments on commit b43fe93

Please sign in to comment.
You can’t perform that action at this time.