【问题标题】:In "Download build artifacts" task, how do I specify "Build pipeline" as variable value?在“下载构建工件”任务中,如何将“构建管道”指定为变量值?
【发布时间】:2021-02-22 21:22:55
【问题描述】:

我正在尝试将下载构建工件任务中的“构建管道”值指定为变量值,例如“$(Pipeline)”。

但经典编辑器不允许这样做。

有没有办法做到这一点?

【问题讨论】:

    标签: azure-devops azure-pipelines devops


    【解决方案1】:

    看起来您在使用经典编辑器时无法在此输入中使用变量,但如果您使用 YAML 管道,则可以使用变量:

    variables: 
      buildName: TestBuild
    
    steps:
      - task: DownloadBuildArtifacts@0
        inputs:
          buildType: 'specific'
          project: 'xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx'
          pipeline: '$(buildName)'
          buildVersionToDownload: 'latest'
          downloadType: 'single'
          downloadPath: '$(System.ArtifactsDirectory)'
          artifactName: test
    

    如果您仍想使用经典编辑器,您可以通过将构建导出到 json 来“破解”系统:

    打开 json 并用变量替换其中的值,然后导入构建:

    结果:

    【讨论】:

      【解决方案2】:

      我们能否看到更完整的屏幕截图,说明您要完成的工作?为此有两个任务,“下载构建工件”和“下载管道工件”,变量引用都没有给我带来任何麻烦:

      【讨论】:

      • 他试图在构建是“特定运行”然后在“构建管道”字段中放置一个变量。不在“工件名称”字段中。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-31
      • 2021-04-12
      相关资源
      最近更新 更多