Skip to content

Commit

Permalink
[FIX JENKINS-41765] Allow groovy CLI command via SSH
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Feb 6, 2017
1 parent c4dcffa commit 0d3d6b6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core/src/main/java/hudson/cli/GroovyCommand.java
Expand Up @@ -71,14 +71,17 @@ protected int run() throws Exception {
binding.setProperty("stdout",stdout);
binding.setProperty("stderr",stderr);
binding.setProperty("channel",channel);
String j = getClientEnvironmentVariable("JOB_NAME");
if (j!=null) {
Item job = Jenkins.getActiveInstance().getItemByFullName(j);
binding.setProperty("currentJob", job);
String b = getClientEnvironmentVariable("BUILD_NUMBER");
if (b!=null && job instanceof AbstractProject) {
Run r = ((AbstractProject) job).getBuildByNumber(Integer.parseInt(b));
binding.setProperty("currentBuild", r);

if (channel != null) {
String j = getClientEnvironmentVariable("JOB_NAME");
if (j != null) {
Item job = Jenkins.getActiveInstance().getItemByFullName(j);
binding.setProperty("currentJob", job);
String b = getClientEnvironmentVariable("BUILD_NUMBER");
if (b != null && job instanceof AbstractProject) {
Run r = ((AbstractProject) job).getBuildByNumber(Integer.parseInt(b));
binding.setProperty("currentBuild", r);
}
}
}

Expand Down

0 comments on commit 0d3d6b6

Please sign in to comment.