【问题标题】:Azure DevOps CI/CD pipeline No package found errorAzure DevOps CI/CD 管道未找到包错误
【发布时间】:2022-07-04 15:05:41
【问题描述】:

我有一个 Azure DevOps CI/CD 管道:

trigger:
- master
pool:
  vmImage: ubuntu-latest
variables:
  buildConfiguration: 'Release'
stages:
- stage: Build
  jobs:
  - job: Build
    displayName: 'Build'
    steps:
      - task: DotNetCoreCLI@2
        inputs:
          command: 'build'
          configuration: 'Release'
          projects: |
            $(System.DefaultWorkingDirectory)/src/*.csproj
          arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration $(buildConfiguration)
      - task: ArchiveFiles@2
        displayName: 'Archive files'
        inputs:
          rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
          includeRootFolder: false
          archiveType: zip
          archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
          replaceExistingArchive: true
      - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        artifact: drop
- stage: Test
  dependsOn: Build
  condition: succeeded()
  jobs:
    - job: Deploy
      displayName: 'Deploy to Test'
      steps:
      - task: AzureRmWebAppDeployment@4
        inputs:
          ConnectionType: 'AzureRM'
          azureSubscription: 'xxx'
          appType: 'webApp'
          WebAppName: 'xxx'
          package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

当我运行它时,我得到了

Error: No package found with specified pattern: /home/vsts/work/1/drop/13325.zip<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

构建阶段产生了一个工件,它在'drop'目录中,所以我无法理解为什么发布任务找不到它?

【问题讨论】:

  • 你能不能试试 package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' '$(Build.StagingDirectory)/**/*.zip' 。当您定义管道时,工件应位于 home/vsts/work/1/a/.. 之类的路径上
  • @GeralexGR 我试过了,但没有用,得到的错误信息略有不同:错误:找不到具有指定模式的包:/home/vsts/work/1/a/**/ *.zip
  • 请先查看 Azure Pipelines 文档。这里的问题是您没有在Test 阶段中​​使用deployment 作业(或从Build 阶段显式下载工件)。文档内容广泛,包括许多如何完成此操作的示例。
  • @DanielMann 我不确定显式下载是否会有所帮助,我在部署前尝试过使用显式下载的相同管道,但没有成功。
  • @anystacy 您发布的管道未下载工件。没有可以想象的方式它会起作用。你必须要么明确地- download 它,要么使用deployment 工作。如果您在下载工件后仍然收到错误,则您有一个 单独 问题,即您没有提供正确的路径。您可以查看- download 步骤以确认位置并进行适当的更新。

标签: azure-devops azure-pipelines-yaml


【解决方案1】:

正如@Daniel 所指出的,您还需要在Test 阶段中​​执行下载工件任务,因为不同的阶段保持不同的工作目录。

- stage: Test
  dependsOn: Build
  condition: succeeded()
  jobs:
    - job: Deploy
      displayName: 'Deploy to Test'
      steps:
      - task: DownloadBuildArtifacts@1
        inputs:
          buildType: 'current'
          downloadType: 'single'
          artifactName: 'drop'
          downloadPath: '$(System.ArtifactsDirectory)'      
      - task: AzureRmWebAppDeployment@4
        inputs:
          ConnectionType: 'AzureRM'
          azureSubscription: 'xxx'
          appType: 'webApp'
          WebAppName: 'xxx'
          package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 2020-12-20
    • 2020-10-13
    • 2020-09-01
    • 2021-06-13
    • 2021-09-14
    • 1970-01-01
    相关资源
    最近更新 更多