Skip to content

Commit

Permalink
[JENKINS-41511] Don't try to set slaveAgentPort when it is enforced
Browse files Browse the repository at this point in the history
(cherry picked from commit 5b9c10d)
  • Loading branch information
Vlatombe authored and olivergondza committed Feb 15, 2017
1 parent e46099a commit 19d2b2c
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -79,7 +79,7 @@ public int getSlaveAgentPort() {
* @since 2.24
* @return true if the slave agent port is enforced on this instance.
*/
@Restricted(DoNotUse.class) // only for index.groovy
@Restricted(NoExternalUse.class) // only for index.groovy
public boolean isSlaveAgentPortEnforced() {
return Jenkins.getInstance().isSlaveAgentPortEnforced();
}
Expand Down Expand Up @@ -114,10 +114,12 @@ public boolean configure(StaplerRequest req, JSONObject json) throws hudson.mode
j.setDisableRememberMe(security.optBoolean("disableRememberMe", false));
j.setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm"));
j.setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization"));
try {
j.setSlaveAgentPort(new ServerTcpPort(security.getJSONObject("slaveAgentPort")).getPort());
} catch (IOException e) {
throw new hudson.model.Descriptor.FormException(e, "slaveAgentPortType");
if (!isSlaveAgentPortEnforced()) {
try {
j.setSlaveAgentPort(new ServerTcpPort(security.getJSONObject("slaveAgentPort")).getPort());
} catch (IOException e) {
throw new hudson.model.Descriptor.FormException(e, "slaveAgentPortType");
}
}
Set<String> agentProtocols = new TreeSet<>();
if (security.has("agentProtocol")) {
Expand Down

0 comments on commit 19d2b2c

Please sign in to comment.