0
votes

I am trying to establish a pipeline by using azure cloud and devops. But I got an error below while deploying from succeeded building. How can I solve this issue?

I read an article it is awesome "http://www.alessandromoura.com.br/2020/04/23/azure-devops-publish-and-download-artifacts/"

I applied your rule sets but I got error always below :

Error: No package found with specified pattern: D:\a\r1\a***.zip
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.

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)"
1
Where are you publishing a pipeline artifact? You can't download a pipeline artifact unless you publish one first. The blog post is wrong or offering incomplete information. Look at the official documentation.Daniel Mann
I have no idea about that. So I can not answer "Where are you publishing a pipeline artifact?" how can I write correct yaml? Or whatelse.Thak you.ALEXALEXIYEV
Start by looking at the documentation.Daniel Mann

1 Answers

1
votes

Your pipeline creates and pushes image to container registry so you don't have there pipeline artifacts. This is why DownloadPipelineArtifact throws error.

DownloadPipelineArtifact makes sens only if you use PublishPipelineArtifact before. This doc - Publish and download artifacts in Azure Pipelines describe it very well.

There is also a way to download artifacts from another pipeline - but it requires to use resource, but you don't have defined pipeline resource in your pipeline.

So all works as expected. Can you explain what actually do you want to download and what achieve by that?