I need to use Java 14 on a hosted agent (macos-12) and I'm trying to install it through a script and then use the JavaToolInstaller task to make it available.
I have modified the script from https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/java-tool-installer?view=azure-devops
jobs:
- job: RunApiTests
pool:
vmImage: macOS-12
condition: ne(variables['Build.SourceBranch'], 'refs/heads/main')
steps:
- task: JavaToolInstaller@0
displayName: Install Java 14
inputs:
versionSpec: '14'
jdkArchitectureOption: 'x64'
jdkSourceOption: AzureStorage
azureResourceManagerEndpoint: {azureResourceManagerEndpoint}
azureStorageAccountName: {azureStorageAccountName}
azureContainerName: openjdk
azureCommonVirtualFile: 'openjdk-14.0.2.zip'
jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk14'
cleanDestinationDirectory: false
Below is the error I am getting:
##[error]JDK file is not valid. Verify if JDK file contains only one root folder with 'bin' inside.
I downloaded the 14.0.2 (build 14.0.2+12) jdk
for Mac from https://jdk.java.net/archive/ and I compressed only the Home
folder to a zip file because bin
is in there.
So, as per the requirement, the zip file contains only one root folder 'Home'
with bin
inside.
I need help on why I'm getting this error.
I tried to test your yaml in my pipeline and it works. The following are my steps.
I downloaded this package:
In my zip, I have these files:
Uploaded to the storage account.
Yaml:
trigger:
- none
pool:
vmImage: macos-12
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '14'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'AzureStorage'
azureResourceManagerEndpoint: 'myEndpoint'
azureStorageAccountName: 'teststorage'
azureContainerName: 'test'
azureCommonVirtualFile: 'homefolder.zip'
jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk14'
cleanDestinationDirectory: false