从另一个管道 Azure 下载管道工件

Download pipeline artifact from another pipeline Azure

我是这个管道的新手,我正在尝试构建一种自动化的方式来为我的应用程序构建 .msi 安装程序文件。

我有 2 个项目 .Net CorePython,所以我创建了 2 个管道。 .Net Core 管道将构建文件并将其保存在一个位置,Python 管道使用这些文件(来自该位置)作为其依赖项并构建一个新的 .msi 文件,即管道中的最后一部分 newsetup.py 构建 .msi,我将向其传递 .Net Core 管道输出文件的位置。

我得到的错误是 Artifact dropcli was not found for build 150.

.Net Core 管道脚本:

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(Build.ArtifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    
- task: PublishPipelineArtifact@1
  inputs:
   targetPath: '$(Pipeline.Workspace)'
   artifact: 'dropcli'
   publishLocation: 'pipeline'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

Python 管道脚本:

- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'current'
    artifactName: 'dropcli'
    targetPath: '$(Pipeline.Workspace)'

- task: PythonScript@0
  inputs:
    scriptSource: 'filePath'
    scriptPath: 'src/python/newsetup.py'
    arguments: 'bdist_msi $(Pipeline.Workspace)'

此外,如果我在某处指定内部版本号,那么在创建新管道时不会出现问题吗?或者这是一个限制?

在您的 DownloadPipelineArtifact@2 任务中,buildType 的值为 current。这意味着您正在下载当前 运行 中的工件。您应该将 buildType 设置为 specific。以下是从特定管道下载最新工件的示例:

- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'specific'
    project: '{project id}'
    definition: '{pipeline id}'
    buildVersionToDownload: 'latest'
    artifactName: 'dropcli'
    targetPath: '$(Pipeline.Workspace)'

您可以点击任务顶部的“设置”,这将帮助您更轻松地完成任务。

单击Download Pipeline Artifacts task了解有关此任务参数的详细信息。

If i specify the build number somewhere won't it be an issue when a new pipeline is created? Or is that an limitation?

如前所述,您不需要指定内部版本号,您需要指定的是管道定义id。您可以下载管道的最新工件或管道特定构建的工件。