JavaToolInstaller@0 - Java 工具安装程序 v0 任务
使用此任务可从用户提供的 Azure Blob 或工具缓存获取特定版本的 Java,并设置 JAVA_HOME
。
语法
# Java tool installer v0
# Acquire a specific version of Java from a user-supplied Azure blob or the tool cache and sets JAVA_HOME.
- task: JavaToolInstaller@0
inputs:
versionSpec: '8' # string. Required. JDK version. Default: 8.
jdkArchitectureOption: # 'x64' | 'x86'. Required. JDK architecture.
jdkSourceOption: # 'AzureStorage' | 'LocalDirectory' | 'PreInstalled'. Required. JDK source.
#jdkFile: # string. Required when jdkSourceOption == LocalDirectory. JDK file.
#azureResourceManagerEndpoint: # string. Required when jdkSourceOption == AzureStorage. Azure subscription.
#azureStorageAccountName: # string. Required when jdkSourceOption == AzureStorage. Storage account name.
#azureContainerName: # string. Required when jdkSourceOption == AzureStorage. Container name.
#azureCommonVirtualFile: # string. Required when jdkSourceOption == AzureStorage. Common virtual path.
#jdkDestinationDirectory: # string. Required when jdkSourceOption != PreInstalled. Destination directory.
#azureResourceGroupName: # string. Optional. Use when jdkSourceOption == AzureStorage. Resource Group name.
#cleanDestinationDirectory: true # boolean. Optional. Use when jdkSourceOption != PreInstalled. Clean destination directory. Default: true.
#createExtractDirectory: true # boolean. Optional. Use when jdkSourceOption != PreInstalled. Create directory for extracting. Default: true.
# Java tool installer v0
# Acquire a specific version of Java from a user-supplied Azure blob or the tool cache and sets JAVA_HOME.
- task: JavaToolInstaller@0
inputs:
versionSpec: '8' # string. Required. JDK version. Default: 8.
jdkArchitectureOption: # 'x64' | 'x86'. Required. JDK architecture.
jdkSourceOption: # 'AzureStorage' | 'LocalDirectory' | 'PreInstalled'. Required. JDK source.
#jdkFile: # string. Required when jdkSourceOption == LocalDirectory. JDK file.
#azureResourceManagerEndpoint: # string. Required when jdkSourceOption == AzureStorage. Azure subscription.
#azureStorageAccountName: # string. Required when jdkSourceOption == AzureStorage. Storage account name.
#azureContainerName: # string. Required when jdkSourceOption == AzureStorage. Container name.
#azureCommonVirtualFile: # string. Required when jdkSourceOption == AzureStorage. Common virtual path.
#jdkDestinationDirectory: # string. Required when jdkSourceOption != PreInstalled. Destination directory.
#cleanDestinationDirectory: true # boolean. Optional. Use when jdkSourceOption != PreInstalled. Clean destination directory. Default: true.
#createExtractDirectory: true # boolean. Optional. Use when jdkSourceOption != PreInstalled. Create directory for extracting. Default: true.
# Java tool installer v0
# Acquire a specific version of Java from a user-supplied Azure blob or the tool cache and sets JAVA_HOME.
- task: JavaToolInstaller@0
inputs:
versionSpec: '8' # string. Required. JDK version. Default: 8.
jdkArchitectureOption: # 'x64' | 'x86'. Required. JDK architecture.
jdkSourceOption: # 'AzureStorage' | 'LocalDirectory' | 'PreInstalled'. Required. JDK source.
#jdkFile: # string. Required when jdkSourceOption == LocalDirectory. JDK file.
#azureResourceManagerEndpoint: # string. Required when jdkSourceOption == AzureStorage. Azure subscription.
#azureStorageAccountName: # string. Required when jdkSourceOption == AzureStorage. Storage account name.
#azureContainerName: # string. Required when jdkSourceOption == AzureStorage. Container name.
#azureCommonVirtualFile: # string. Required when jdkSourceOption == AzureStorage. Common virtual path.
#jdkDestinationDirectory: # string. Required when jdkSourceOption != PreInstalled. Destination directory.
#cleanDestinationDirectory: true # boolean. Optional. Use when jdkSourceOption != PreInstalled. Clean destination directory. Default: true.
# Java tool installer v0
# Acquire a specific version of Java from a user-supplied Azure blob or the tool cache and sets JAVA_HOME.
- task: JavaToolInstaller@0
inputs:
versionSpec: '8' # string. Required. JDK version. Default: 8.
jdkArchitectureOption: # 'x64' | 'x86'. Required. JDK architecture.
jdkSourceOption: # 'AzureStorage' | 'LocalDirectory'. Required. JDK source.
#jdkFile: # string. Required when jdkSourceOption == LocalDirectory. JDK file.
#azureResourceManagerEndpoint: # string. Required when jdkSourceOption == AzureStorage. Azure subscription.
#azureStorageAccountName: # string. Required when jdkSourceOption == AzureStorage. Storage account name.
#azureContainerName: # string. Required when jdkSourceOption == AzureStorage. Container name.
#azureCommonVirtualFile: # string. Required when jdkSourceOption == AzureStorage. Common virtual path.
jdkDestinationDirectory: # string. Required. Destination directory.
#cleanDestinationDirectory: true # boolean. Clean destination directory. Default: true.
# Java Tool Installer v0
# Acquires a specific version of Java from a user supplied Azure blob or the tools cache and sets JAVA_HOME. Use this task to change the version of Java used in Java tasks.
- task: JavaToolInstaller@0
inputs:
versionSpec: '8' # string. Required. JDK version. Default: 8.
jdkArchitectureOption: # 'x64' | 'x86'. Required. JDK architecture.
jdkSourceOption: # 'AzureStorage' | 'LocalDirectory'. Required. JDK source.
#jdkFile: # string. Required when jdkSourceOption == LocalDirectory. JDK file.
#azureResourceManagerEndpoint: # string. Required when jdkSourceOption == AzureStorage. Azure subscription.
#azureStorageAccountName: # string. Required when jdkSourceOption == AzureStorage. Storage account name.
#azureContainerName: # string. Required when jdkSourceOption == AzureStorage. Container name.
#azureCommonVirtualFile: # string. Required when jdkSourceOption == AzureStorage. Common virtual path.
jdkDestinationDirectory: # string. Required. Destination directory.
#cleanDestinationDirectory: true # boolean. Clean destination directory. Default: true.
输入
versionSpec
-
JDK 版本
string
。 必填。 默认值:8
。
指定要在路径上可用的 JDK 版本。 使用整数版本,例如 10。
jdkArchitectureOption
-
JDK 体系结构
string
。 必填。 允许的值:x64
、x86
。
指定 JDK 的体系结构(x86
,x64
)。
jdkSourceOption
-
JDK 源
string
。 必填。 允许的值:AzureStorage
(Azure 存储)、LocalDirectory
(本地目录)、PreInstalled
(预安装)。
指定压缩 JDK 的源。 源可以是代理或源存储库上的 Azure Blob 存储或本地目录,也可以使用预安装的 Java 版本(可用于Microsoft托管代理)。 请参阅以下示例,了解如何使用预安装的 Java 版本。
jdkSourceOption
-
JDK 源
string
。 必填。 允许的值:AzureStorage
(Azure 存储)、LocalDirectory
(本地目录)。
指定压缩 JDK 的源。 源可以是代理或源存储库上的 Azure Blob 存储或本地目录,也可以使用预安装的 Java 版本(可用于Microsoft托管代理)。 请参阅以下示例,了解如何使用预安装的 Java 版本。
jdkFile
-
JDK 文件
string
。
jdkSourceOption == LocalDirectory
时是必需的。
指定包含压缩 JDK 的 JDK 存档文件的路径。 该路径可能位于源存储库中,也可以是代理上的本地路径。 该文件应是包含根级别或单个目录中的 bin 文件夹的存档(.zip、.tar.gz、.7z)。 MacOS 支持.pkg和.dmg文件,其中仅包含一个.pkg文件。
azureResourceManagerEndpoint
-
Azure 订阅
string
。
jdkSourceOption == AzureStorage
时是必需的。
指定 JDK 的 Azure 资源管理器订阅。
azureStorageAccountName
-
存储帐户名称
string
。
jdkSourceOption == AzureStorage
时是必需的。
指定 Azure 经典或资源管理器存储帐户。 选择 JDK 所在的存储帐户名称。
azureContainerName
-
容器名称
string
。
jdkSourceOption == AzureStorage
时是必需的。
指定 JDK 所在的存储帐户中容器的名称。
azureCommonVirtualFile
-
通用虚拟路径
string
。
jdkSourceOption == AzureStorage
时是必需的。
指定 Azure 存储容器中 JDK 的路径。
jdkDestinationDirectory
-
目标目录
string
。
jdkSourceOption != PreInstalled
时是必需的。
指定应提取 JDK 的目标目录。 在 Linux 和 Windows 上,这用作 JDK 安装的目标目录。 在 macOS 上,此目录用作用于提取.dmg的临时文件夹,因为 macOS 不支持将 JDK 安装到特定目录。
jdkDestinationDirectory
-
目标目录
string
。 必填。
指定应提取 JDK 的目标目录。 在 Linux 和 Windows 上,这用作 JDK 安装的目标目录。 在 macOS 上,此目录用作用于提取.dmg的临时文件夹,因为 macOS 不支持将 JDK 安装到特定目录。
azureResourceGroupName
-
资源组名称
string
。 自选。 当 jdkSourceOption == AzureStorage
时使用。
存储帐户的资源组名称。
cleanDestinationDirectory
-
清理目标目录
boolean
。 自选。 当 jdkSourceOption != PreInstalled
时使用。 默认值:true
。
指定在 JDK 提取到目标目录之前清理目标目录的选项。
cleanDestinationDirectory
-
清理目标目录
boolean
。 默认值:true
。
指定在 JDK 提取到目标目录之前清理目标目录的选项。
createExtractDirectory
-
创建用于提取 的目录
boolean
。 自选。 当 jdkSourceOption != PreInstalled
时使用。 默认值:true
。
默认情况下,该任务创建类似于用于提取 JDK 的 JAVA_HOME_8_X64_OpenJDK_zip
的目录。 此选项禁用该文件夹的创建,如果设置为 false
,则 JDK 位于 jdkDestinationDirectory
的根目录中。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
没有。
言论
使用此任务可从用户提供的 Azure Blob、源或代理中的位置或工具缓存获取特定版本的 Java。 该任务还设置 JAVA_HOME
环境变量。
使用此任务可更改 Java 任务中使用的 Java 版本。
注意
若要在 macOS 上运行 Java 工具安装程序 任务,需要运行代理的用户有权在没有密码的情况下执行 sudo 命令。 可以按照后续步骤启用此权限:
- 运行 sudo visudo 命令。 此时会打开 sudoers 文件进行编辑。
- 转到文件底部并添加以下行:
user ALL=NOPASSWD: /usr/sbin/installer
(将用户替换为实际用户别名)。- 保存并关闭文件。
例子
下面是从 Linux 上的本地目录获取存档文件的示例。 该文件应是 JAVA_HOME
目录的存档(.zip、.gz),因此它包括 bin
、lib
、include
、jre
等目录。
- task: JavaToolInstaller@0
inputs:
versionSpec: "11"
jdkArchitectureOption: x64
jdkSourceOption: LocalDirectory
jdkFile: "/builds/openjdk-11.0.2_linux-x64_bin.tar.gz"
jdkDestinationDirectory: "/builds/binaries/externals"
cleanDestinationDirectory: true
下面是从 Azure 存储下载存档文件的示例。
该文件应是 JAVA_HOME
目录的存档(.zip、.gz),因此它包括 bin
、lib
、include
、jre
等目录。
- task: JavaToolInstaller@0
inputs:
versionSpec: '6'
jdkArchitectureOption: 'x64'
jdkSourceOption: AzureStorage
azureResourceManagerEndpoint: myARMServiceConnection
azureStorageAccountName: myAzureStorageAccountName
azureContainerName: myAzureStorageContainerName
azureCommonVirtualFile: 'jdk1.6.0_45.zip'
jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk6'
cleanDestinationDirectory: false
下面是使用“预安装”功能的示例。 此功能允许你使用预安装在 Microsoft 托管代理上的 Java 版本。 可以在托管代理表中
- task: JavaToolInstaller@0
inputs:
versionSpec: '8'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
要求
要求 | 描述 |
---|---|
管道类型 | YAML,经典版本,经典版本 |
运行时间 | 代理,DeploymentGroup |
需求 | 没有 |
功能 | 运行此任务满足以下 要求 同一作业中的任何后续任务:Java、JDK |
命令限制 | 此任务使用以下 命令限制运行: 受限 |
|
此任务有权 设置以下变量:PATH、JAVA_HOME* |
代理版本 | 2.182.1 或更高版本 |
任务类别 | 工具 |
要求 | 描述 |
---|---|
管道类型 | YAML,经典版本,经典版本 |
运行时间 | 代理,DeploymentGroup |
需求 | 没有 |
功能 | 运行此任务满足以下 要求 同一作业中的任何后续任务:Java、JDK |
命令限制 | 任何 |
|
任何 |
代理版本 | 所有支持的代理版本。 |
任务类别 | 工具 |
要求 | 描述 |
---|---|
管道类型 | YAML,经典版本,经典版本 |
运行时间 | 代理,DeploymentGroup |
需求 | 没有 |
功能 | 运行此任务满足以下 要求 同一作业中的任何后续任务: Java |
命令限制 | 任何 |
|
任何 |
代理版本 | 所有支持的代理版本。 |
任务类别 | 工具 |
另请参阅
有关工具安装程序和示例的说明,请参阅 工具安装程序。