Jenkins Slave Environment Variable Refresh

僤鯓⒐⒋嵵緔 提交于 2019-12-01 14:54:00

问题


I have a Jenkins Slave (A Windows PC) which has the JAVA_HOME environment variable. I updated the Java version on the Slave so I also updated the Environment Variable.

When I look at the system properties of this Slave via Jenkins web interface the JAVA_HOME property is reported as the old one.

Running echo %PATH% on the Windows PC shows the correct values. Running println System.getenv("PATH") on the Jenkins Node script console for the Slave shows the old JAVA_HOME value.

I have tried to delete and add the Slave again and restarted Jenkins server. Still the old value is not updated.

Any thoughts?


回答1:


Hudson/Jenkins does not use the slave environment variables as it supports multiple java versions so you configure the java home environment variables in the GUI.

What you need to do is go to Manage Hudson/Jenkins then choose Manage Nodes. Choose the Node you want to configure from the list and then choose Configure. Down the bottom there's a Node Properties section. Check the Tool Locations checkbox. Click on Add then Select your JDK in the dropdown list and add the new path to it.




回答2:


This is a bug in Jenkins: https://issues.jenkins-ci.org/browse/JENKINS-27739

3 ways to solve (I have personally confirmed each):

  1. Update Jenkins to >=1.617 (Recommended)
  2. Restart Jenkins master
  3. Delete Jenkins slave, then re-add it



回答3:


Restart the slave, this fixed the issue on my configuration.




回答4:


You can update your Jenkins version, it will solve it. Otherwise this worked for me (Jenkins 1.6, build/test node: MacOSX Mojave):

First install java 8 in your build/test node using the commands:

brew update
brew cask install caskroom/versions/java8

Then in Jenkins web panel click on your build/test node, then click on Configure and then click in the Advanced... button, this will show you multiple text fields. Then in the JavaPath field add the path to your java 8.

For me this path is like:

/Library/Java/JavaVirtualMachines/jdk1.8.X_XXX.jdk/Contents/Home/bin/java

Note: remember replace X_XXX with your java 8 version before.

Then Save.

After that disconnect the build/test node and connect it again. This should solve the problem.

Source



来源:https://stackoverflow.com/questions/8523749/jenkins-slave-environment-variable-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!