Found a solution, here it is in case anyone else stumbles upon same problem:
In my Jenkinsfile I set up java through the global env variable: String jdkHome = "${tool name: 'jdk8', type: 'hudson.model.JDK'}" env.PATH = "${jdkHome}/bin:${env.PATH}" And that is not recommended as per point 9 of this list: https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin Using the withEnv{} wrapper instead worked perfectly: withEnv(["JAVA_HOME=${ tool 'jdk8' }", "PATH+MAVEN=${tool 'maven3.3.x'}/bin:${env.JAVA_HOME}/bin"]) { sh "mvn ..." } Best regards, stefan. On Fri, Aug 4, 2017 at 4:53 PM, ST <st.mailingli...@gmail.com> wrote: > (sorry, email got sent too early, nasty default shortcuts) > > I have a Jenkinsfile pipeline build that uses our maven project. I also > have configured latest jdk8 (1.8.0_144) in the Global Tool Configuration. > When building the project on master node, the correct JDK is picked up: > > *15:11:49* + > /export/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.3.x/bin/mvn > --batch-mode --show-version [more maven args...] > > *15:11:49* Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; > 2015-11-10T17:41:47+01:00)*15:11:49* Maven home: > /export/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.3.x*15:11:49* > Java version: 1.8.0_144, vendor: Oracle Corporation*15:11:49* Java home: > /export/jenkins/tools/hudson.model.JDK/jdk8/jre*15:11:49* Default locale: > en_US, platform encoding: UTF-8*15:11:49* OS name: "linux", version: > "3.10.0-514.26.2.el7.x86_64", arch: "amd64", family: "unix" > > > However when trying to build the same project on another build node, the > build uses the system-default JDK installed on the build node: > > *16:22:59* + > /export/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.3.x/bin/mvn > --batch-mode --show-version [more maven args...]*16:22:59* Apache Maven 3.3.9 > (bb52d8502b132ec0a5a3f4c09453c07478323dc5; > 2015-11-10T17:41:47+01:00)*16:22:59* Maven home: > /export/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.3.x*16:22:59* > Java version: 1.8.0_141, vendor: Oracle Corporation*16:22:59* Java home: > /usr/java/jdk1.8.0_141/jre*16:22:59* Default locale: en_US, platform > encoding: UTF-8*16:22:59* OS name: "linux", version: > "3.10.0-514.26.2.el7.x86_64", arch: "amd64", family: "unix" > > The Global Tool Configuration seems to work fine for maven tool ,so why > not for the jdk tool? > > The Jenkins slave nodes are launched as "Launch slave agents via SSH", in > case that is relevant. > > Environment: Latest jenkins v3.72 with latest plugins, incl. SSH Slaves > plugin v1.20. > > Any ideas what could be wrong? > stefan. > > On Fri, Aug 4, 2017 at 4:48 PM, ST <st.mailingli...@gmail.com> wrote: > >> I have a Jenkinsfile pipeline build that uses our maven project. I also >> have configured latest jdk8 (1.8.0_144) in the Global Tool Configuration. >> When building the project on master node, the correct JDK is picked up: >> >> *15:11:49* + >> /export/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.3.x/bin/mvn >> --batch-mode --show-version [more maven args...] >> >> *15:11:49* Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; >> 2015-11-10T17:41:47+01:00)*15:11:49* Maven home: >> /export/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.3.x*15:11:49* >> Java version: 1.8.0_144, vendor: Oracle Corporation*15:11:49* Java home: >> /export/jenkins/tools/hudson.model.JDK/jdk8/jre*15:11:49* Default locale: >> en_US, platform encoding: UTF-8*15:11:49* OS name: "linux", version: >> "3.10.0-514.26.2.el7.x86_64", arch: "amd64", family: "unix" >> >> >> >> However when trying to build the same project on another build node, the >> build uses the default JDK installed on the build node: >> >> >> >> The Jenkins slave nodes are configured as >> > > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CABwQARuG2%3DC-RrPHB_8VW0fXgyKLq6YsJ%3D5EWx7WfkfdqT%3Do1Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.