admin管理员组

文章数量:1332383

We are using Jenkins with Docker Cloud Agents. Our build image contains several jdk (8, 11, 17, 21). Our jobs are using Jenkinsfiles from the Git Repos.

To select the proper jdk for a build we use the following:

#!groovy

pipeline {
    agent {
        label 'our-label-name'
    }

    tools {
        jdk 'adoptOpenJDK-8'
    }
    ...
}

Setting the jdk results in the correct value for JAVA_HOME and also PATH contains the proper jdk installation.

But LD_LIBRARY_PATH does always contain the path to jdk 17. (I'm not sure why always exactly 17. Perhaps because jenkins and agent is running on this version.)

So the result is like this:

JAVA_HOME=/usr/lib/jvm/java-8-openjdk
PATH=/usr/lib/jvm/java-8-openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LD_LIBRARY_PATH=/usr/lib/jvm/java-17-openjdk/lib/server:/usr/lib/jvm/java-17-openjdk/lib:/usr/lib/jvm/java-17-openjdk/../lib

And with this setting the wrong java version is used:

java -version
openjdk version "17.0.10" 2024-01-16

When I manually clean LD_LIBRARY_PATH the correct java version is used.

So why isn't LD_LIBRARY_PATH pointing to the correct jdk?

Or if unknown why this is happending, what can I do to achieve this? As we have hundreds of jobs, added some manual setting of LD_LIBRARY_PATH to each job is not a valid solution. If there is just one config place to fix this, it would be ok.

本文标签: