0

I have a weird issue when executing an ADO release using my self-hosted agents (running in a Ubuntu VM). These agents are configured as a service as well. When I ran the release, they return this error:

##[error]Unhandled: Failed to find the specified JDK version. Please ensure the specified JDK version is installed on the agent and the environment variable 'JAVA_HOME_11_X64' exists and is set to the location of a corresponding JDK or use the Java Tool Installer task to install the desired JDK.

I've checked the value of Java variable, and it's configured ok.

What is weird in this situation is that if I execute the agent manually, and not as a service, the deployment works correctly...

Any idea about what could be wrong here?

Regards! [1]: https://i.stack.imgur.com/DwV2e.jpg

AlphaModder
  • 3,266
  • 2
  • 28
  • 44
  • Hi, it should be noted that for any `environment variable` changes(after the agent service is started or is currently running); we need to [update environment variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops#service-update-environment-variables). – Jay Apr 28 '21 at 10:39
  • Hi Guillermo, any update about this issue? If my answer helps you handle the issue, please do not forget to [accept it](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). And if not, please feel free to let us know:) – Mr Qian May 06 '21 at 09:51
  • Hi @PerryQian-MSFT I'm not tested yet, sorry. I will try to configure as a service following your recomendations and reply over your message. – Guillermo Abdon May 07 '21 at 12:14

2 Answers2

1

Under vsts-agent-linux-x64-2.204.0.tar.gz you will have

  1. config.sh
  2. env.sh

by default env.sh does not have entry for JAVA_HOME_11_X64 and this env.sh is used to add all system capabilities. if JAVA_HOME_11_X64 needs to be added as system capabilities make your you edit the .env file and add JAVA_HOME_11_X64. if added after build agent is stared then you need to restart the agent gain to show as capabilities.

I have added the script for

if [ ! -f ".env" ]; then touch .env fi echo "JAVA_HOME_11_X64=${JAVA_HOME_11_X64}" >>.env

before config.sh is executed

anil kumar
  • 21
  • 2
0

Make sure you have added JAVA_HOME_11_X64 system environment variable into VM.

Then, you should re-run the run.cmd to update the environment to your agent tool.

After that, please check Project Settings-->Pipeline-->Agent Pools-->your agent tool--> agent--> click more for update agent. And you could also enter Capabilities to check if there is a environment variable called JAVA_HOME_11_X64. If not, you could also add its value under User-defined capabilities.

Last, use a pipeline to run javatoolinstaller task for your self-agent, and then you can use the java11 jdk directly.

Besides, check the self agent security permission and you have the right.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41