我一直在尝试为 Business Central 设置 CICD 管道,并想知道在运行时使用什么类型的 Azure DevOps 代理来运行管道? (Azure 托管与本地托管),因为这将改变构建的完成方式。
请告诉我这是否可以实现。到目前为止,我已经实现了一个逻辑,我检查管道的名称,如果它以“self_hosted”开头,那么我知道它是本地安装等等。
Agent.Name
”的值来识别代理类型:
Hosted Agent
”。在某些情况下,自托管代理可能已配置为与 Microsoft 托管代理
相同的名称 (
Hosted Agent
)。此时,您还可以使用预定义变量“Agent.CloudId
”的值来识别代理类型:
请参阅以下示例作为参考:
# azure-pipelines.yml
jobs:
- job: A
strategy:
matrix:
WindowsPool:
poolName: WindowsPool # A pool of self-hosted Windows agents.
LinuxPool:
poolName: LinuxPool # A pool of self-hosted Linux agents.
MsHosted:
poolName: 'Azure Pipelines' # The pool of Microsoft-hosted agents.
pool: $(poolName)
steps:
- checkout: none
- pwsh: |
Write-Host "Agent.Name = $(Agent.Name)"
Write-Host "Agent.CloudId = $(Agent.CloudId)"
Write-Host "Agent.MachineName = $(Agent.MachineName)"
Write-Host "Agent.OS = $(Agent.OS)"
Write-Host "Agent.OSArchitecture = $(Agent.OSArchitecture)"
displayName: 'Show Agent Information'