Skip to content

Commit

Permalink
[FIXED JENKINS-42381] Add PATH+GRADLE and buildEnvVars(...)
Browse files Browse the repository at this point in the history
This ensures that Gradle's bin directory ends up on the PATH when
using the Pipeline tool step. Note that Jenkins' environment variable
management will handle converting "/bin" on Windows if needed, we do
not need to do that explicitly.
  • Loading branch information
abayer authored and wolfs committed Apr 2, 2017
1 parent 4060b4f commit 96e82f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/hudson/plugins/gradle/GradleInstallation.java
Expand Up @@ -63,6 +63,10 @@ public String getHome() {
return super.getHome();
}

@Override
public void buildEnvVars(EnvVars env) {
env.put("PATH+GRADLE", getHome() + "/bin");
}

public String getExecutable(Launcher launcher) throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() {
Expand Down
Expand Up @@ -28,6 +28,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlButton
import com.gargoylesoftware.htmlunit.html.HtmlForm
import com.gargoylesoftware.htmlunit.html.HtmlPage
import com.google.common.base.Joiner
import hudson.EnvVars
import hudson.cli.CLICommandInvoker
import hudson.model.Cause
import hudson.model.FreeStyleBuild
Expand Down Expand Up @@ -348,6 +349,11 @@ task hello << { println 'Hello' }"""))
installation.name == 'myGradle'
installation.home == '/tmp/foo'

def envVars = new EnvVars()
installation.buildEnvVars(envVars)
assert envVars.containsKey("PATH+GRADLE")
assert envVars.get("PATH+GRADLE") == installation.home + "/bin"

// by default we should get the auto installer
def props = installations[0].getProperties()
assert props.size() == 1
Expand Down

0 comments on commit 96e82f0

Please sign in to comment.