Fix commandWithBazelOnPath function in BazelUtils.groovy
Change-Id: I61e2f7574be4e1813b15c8ae491206d404bbfb93
diff --git a/jenkins/lib/src/build/bazel/ci/BazelUtils.groovy b/jenkins/lib/src/build/bazel/ci/BazelUtils.groovy
index c5cbed5..ea944c5 100644
--- a/jenkins/lib/src/build/bazel/ci/BazelUtils.groovy
+++ b/jenkins/lib/src/build/bazel/ci/BazelUtils.groovy
@@ -79,7 +79,15 @@
// Execute a shell/batch command with bazel as a command on the path
def commandWithBazelOnPath(script) {
- this.script.withEnv(["PATH=${new File(this.bazel).parent}:${this.script.env.PATH}",
+ def pathWithBazel = ""
+ if (isWindows) {
+ def bazelDir = bazel.substring(0, bazel.lastIndexOf("\\"))
+ pathWithBazel = "${bazelDir};${this.script.env.PATH}"
+ } else {
+ def bazelDir = bazel.substring(0, bazel.lastIndexOf("/"))
+ pathWithBazel = "${bazelDir}:${this.script.env.PATH}"
+ }
+ this.script.withEnv(["PATH=${PathWithBazel}",
"BAZEL=${this.bazel}"] + envs) {
if (isWindows) {
this.script.bat script