Azure Pipelines 尝试查找正确的环境值存储库签出

问题描述 投票:0回答:1

这条路径是什么管道变量? 我正在寻找这个值的环境变量 我已经尝试过

$(Build.SourcesDirectory)
$(Agent.BuildDirectory)
这些都出现在C盘中,每次运行的所有管道环境变量都有输出源吗?

resources:
  repositories:
  - repository: self
    type: git
    ref: refs/heads/master
...
        steps:
        - checkout: self
...
        - task: PowerShell@2
          displayName: Display Build Dir
          inputs:
            targetType: 'inline'
            script: 'Write-Host "Build Directory Location: `"$(Agent.BuildDirectory)`""' 

        - task: NuGetCommand@2
          displayName: NuGet restore
          inputs:
            solution: '$(BuildParameters.solution)'
            selectOrConfig: config
            nugetConfigPath: '$(Agent.BuildDirectory)/src/tree0/nuget.config'

enter image description here

azure-devops
1个回答
0
投票

预定义变量“

Agent.BuildDirectory
”的值是管道正在工作的代理上的本地路径。预定义变量“
Pipeline.Workspace
”也具有相同的值。

Build.SourcesDirectory
”是 Azure Pipelines 预定义变量,其值是代理上下载源代码文件的本地路径。预定义变量“
Build.Repository.LocalPath
”和“
System.DefaultWorkingDirectory
”也具有相同的值。

Build.SourcesDirectory
”是“
Agent.BuildDirectory
”下的子目录。

例如:

有一个名为

Win11-01
的 Windows Agent,其在 Agent 机器上的安装目录为“
E:\VstsAgents\Win11_01
”,当使用此 Agent 运行作业时,您可能需要使用以下预定义变量:

  1. Agent.WorkFolder
    :此代理的工作目录 (
    E:\VstsAgents\Win11_01\_work
    )。它包含在此代理上运行的所有作业的工作目录。

  2. Agent.BuildDirectory
    :在此代理上运行作业的每个管道的工作目录 (
    E:\VstsAgents\Win11_01\_work\<number>
    )。
    <number>
    文件夹将被命名为
    1
    2
    3
    4
    等,按顺序为每个管道自动生成。例如,
    E:\VstsAgents\Win11_01\_work\1

  3. Pipeline.Workspace
    :与
    Agent.BuildDirectory
    相同。

  4. Build.SourcesDirectory
    :源代码文件下载到的目录(
    E:\VstsAgents\Win11_01\_work\<number>\s
    )。这是 checkout 任务将下载的文件放入的默认目录。在 checkout 任务中,您可以使用
    path
    选项指定不同的目录。

    • 当您设置作业只检出一个存储库时,该存储库的内容将直接放入此目录中。
    • 当您设置作业查看多个存储库时,每个存储库的内容将放入目录“
      E:\VstsAgents\Win11_01\_work\<number>\s\<repository-name>
      ”中。

有关 Azure Pipelines 中更多预定义变量,可以查看文档“使用预定义变量”。


© www.soinside.com 2019 - 2024. All rights reserved.