java - Why is LD_LIBRARY_PATH pointing to the wrong jdk when using Jenkins with Docker Cloud Agents? - Stack Overflow

We are using Jenkins with Docker Cloud Agents. Our build image contains several jdk (8, 11, 17, 21). Ou

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742304290a4418625.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信