我正在将以下 yaml 用于 Azure 管道,但出现错误。 即使该映像已安装 Java 11。 知道我做错了什么吗?
错误:
##[错误]此代理上未预安装 Java 11
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x86'
jdkSourceOption: 'PreInstalled'
TL;DR 在
x64
任务中使用 x86
代替 JavaToolInstaller@0
。
Microsoft 托管代理中没有预装
x86
JDK windows-latest
(截至 2024 年 8 月与 windows-2022
相同)。
示例管道:
trigger: none
pool:
vmImage: 'windows-latest'
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64' # <-------------------------- replaced value
jdkSourceOption: 'PreInstalled'
运行管道时安装程序任务的输出:
Starting: JavaToolInstaller
==============================================================================
Task : Java tool installer
Description : Acquire a specific version of Java from a user-supplied Azure blob or the tool cache and sets JAVA_HOME
Version : 0.243.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/java-tool-installer
==============================================================================
Use preinstalled JDK from C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64
JAVA_HOME is being set to: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64
JAVA_HOME_11_X64 is being set to: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64
Prepending PATH environment variable with directory: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64\bin
Finishing: JavaToolInstaller