Reputation: 1579
My customer has an onprem AzureDevops set-up. I have a dedicated windows server that I use as build server. The agent is installed an runs as user X.
The java application is build using custom scripts created by a 3th party. The build is launched using this script in the YAML :
cmd /c ""C:\Program Files\Git\bin\bash.exe" --login -i --
./deployment/buildKit.sh -kn $(buildnumber) -ah /C/apache-ant-1.10.9""
It all worked fine until we had to change the java version. When logged on with user X interactively on the build server, I installed the new java-version to use, changed JAVA_HOMe, the build script runs fine with no errors using the newly required java version.
If I run SET on the machine as user X I get :
JAVA_HOME=C:\Program Files\Java\jdk-11.0.6+10
I added SET in the YAML to see which JAVA_HOME is used and in the log I get :
JAVA_HOME=C:\Program Files\AdoptOpenJDK\jdk-8.0.275.1-hotspot\
Which is the 'old' version. Hence the build fails. Any Ideas why running the pipeline has a different JAVA_HOME compared to interactif ? And how to solve it ?
Upvotes: 0
Views: 843
Reputation: 4034
The build-agent only reads environment variables on startup of the agent. If you update/install a programm while the agent is running the agent will not know that environment variables have been updated and passes the old values through down to the build processes.
After any update or installation of a program or SDK on a build maschine you should restart the build agent so it will re-read the updated environment variables.
Upvotes: 1