You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure Pipeline(YAML)中下载Azure Artifact(非生成工件)

下载Azure Artifact到Azure Pipeline的方案

明确结论

完全可以将Azure Artifact下载到Azure Pipeline中,不需要下载Build Artifact——二者是Azure DevOps中独立的构件管理体系,互不依赖。

YAML流水线实现步骤

以下是针对已推送至Azure Artifacts的构件的具体下载配置,根据你的Artifact类型选择对应方案:

1. 通用包类型Artifact

使用UniversalPackages任务直接下载,适用于大多数通用格式的Artifact:

steps:
- task: UniversalPackages@0
  inputs:
    command: 'download'
    vstsFeed: '<你的Azure Artifacts源名称/ID>'
    vstsFeedPackage: '<目标包名称>'
    vstsPackageVersion: '<指定版本号,用`*`可拉取最新版本>'
    downloadDirectory: '$(Build.SourcesDirectory)/artifact-downloads' # 自定义下载目录

2. 特定类型包(如NuGet、npm)

如果你的Artifact是语言专属包,用对应生态的任务更高效:

  • NuGet包:
steps:
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln' # 或指定NuGet.config路径
    feedsToUse: 'select'
    vstsFeed: '<你的Azure Artifacts NuGet源>'
    # 任务会自动将包下载到流水线默认依赖目录,如需自定义可添加参数
  • npm包:
steps:
- task: npm@1
  inputs:
    command: 'install'
    workingDir: '$(Build.SourcesDirectory)'
    customRegistry: 'useFeed'
    customFeed: '<你的Azure Artifacts npm源>'

3. 验证下载结果

添加脚本步骤确认文件是否成功下载:

steps:
- script: dir $(Build.SourcesDirectory)/artifact-downloads
  displayName: '检查下载的Artifact内容'

内容的提问来源于stack exchange,提问作者user14925447

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 04:45:31