我正在尝试使用 azure cloud 和 devops 建立管道。但是在从成功的构建中进行部署时,我遇到了以下错误。我该如何解决这个问题?
我读了一篇很棒的文章“http://www.alessandromoura.com.br/2020/04/23/azure-devops-publish-and-download-artifacts/”
我应用了你的规则集,但总是在下面出现错误:
错误:未找到指定模式的包:D:\a\r1\a***.zip
检查任务中提到的包是否作为构建或前一阶段的工件发布并在当前作业中下载。
azure-pipelines.yml :
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- main
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'xxxxx'
imageRepository: 'xxxhelloaspnetcore'
containerRegistry: 'xxxcontainer01.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- download: none
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Artifacts'
inputs:
patterns: '**/*.zip'
path: '$(Build.ArtifactStagingDirectory)'
- task: PowerShell@2
displayName: 'Degug parameters'
inputs:
targetType: Inline
script: |
Write-Host "$(Build.ArtifactStagingDirectory)"
Write-Host "$(System.DefaultWorkingDirectory)"
Write-Host "$(System.ArtifactsDirectory)"
Write-Host "$(Pipeline.Workspace)"
Write-Host "$(System.ArtifactsDirectory)"
答案 0 :(得分:1)
您的管道创建映像并将其推送到容器注册表,因此您没有管道工件。这就是 DownloadPipelineArtifact
抛出错误的原因。
DownloadPipelineArtifact
仅在您之前使用 PublishPipelineArtifact
时才有意义。这doc - Publish and download artifacts in Azure Pipelines很好地描述了它。
还有一种方法可以从另一个管道下载工件 - 但它需要使用 resource,但您没有在管道中定义管道资源。
所以一切都按预期进行。你能解释一下你实际上想要下载什么以及通过它实现什么吗?