Skip to content
Permalink
Browse files

[FIX JENKINS-41765] Allow groovy CLI command via SSH

  • Loading branch information
daniel-beck committed Feb 6, 2017
1 parent c4dcffa commit 0d3d6b65bf134ba01d67908db63212dc54aa1c58
Showing with 11 additions and 8 deletions.
  1. +11 −8 core/src/main/java/hudson/cli/GroovyCommand.java
@@ -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);
}
}
}

0 comments on commit 0d3d6b6

Please sign in to comment.