0

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.

murohima_1
  • 67
  • 1
  • 7

1 Answers1

1

I tried to test your yaml in my pipeline and it works. The following are my steps.

I downloaded this package:

enter image description here

In my zip, I have these files:

enter image description here

Uploaded to the storage account.

enter image description here

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

Result: enter image description here

Miao Tian-MSFT
  • 571
  • 4
  • 5
  • Is there a reason why you left the "azureResourceManagerEndpoint" property empty? – murohima_1 Nov 21 '22 at 10:37
  • Just to hide the name of my subscription as it contains my subscription ID in it. It is not empty. I have edited the answer. – Miao Tian-MSFT Nov 21 '22 at 10:40
  • Was able to fix the issue. I had to select and zip the sub-directions (bin, conf, include etc.). I was zipping the directory which contained the sub-directories before. – murohima_1 Nov 21 '22 at 10:45