Azure (Cloud) - Deployment .. error during downloading artifacts

69 Views Asked by At

During my deployment, an error is thrown: enter image description here

Where can I see more details about this error to got an Idea, what exactly is going wrong here? It's the cloud version of azure on dev.azure.com

The important parts of the sourecode for the "download artifacts" part is the following:

azure-pipeline.yaml

  - template: ./azure-pipelines/build-wordpress.yml
    parameters:
      replaceDomainFrom: ${{ variables.sourceRepo }}
      replaceDomainTo: ${{ variables.targetDomain }}
      buildFrom: "from$(Build.SourceBranchName)"

  - stage: deployStaging
    dependsOn: build
    condition: and(succeeded('build'), eq('${{parameters['environment']}}', 'staging' ))
    jobs:
      - deployment: DeployStaging
        displayName: Deploy to `Staging`-Environment
        environment:
          name: ${{parameters['environment']}}
          resourceType: VirtualMachine
        strategy:
          runOnce:
            preDeploy:
              steps:
                - download: none

                - task: CmdLine@2
                  inputs:
                    script: |
                      mkdir -p ./BACKUPS/$(date +%y%m%d)
                      mysqldump $MYSQL_DB > ./BACKUPS/$(date +%y%m%d)/$(date +%H%M)_wordpress.sql
                    workingDirectory: '/var/www/html'
                    failOnStderr: true
                  env:
                    MYSQL_DB: $(MYSQL_DB)
                  displayName: 'MySQL-DB Backup vom Ziel-System erstellen'

            deploy:
              steps:
                - download: none
                - task: DownloadPipelineArtifact@2
                  inputs:
                    buildType: 'current'
                    patterns: wordpress/**
                    artifact: 'build'
                    path: "/var/www/html/"

                # import mysql dump
                - script: mysql $(MYSQL_DB) < ./from$(Build.SourceBranchName)_wordpress.sql
                  displayName: 'import MySQL Database'
                  workingDirectory: '/var/www/html/wordpress'

                # delete old sql-file:
                - task: DeleteFiles@1
                  displayName: 'delete old MySQL Import-File'
                  inputs:
                    SourceFolder: '/var/www/html/wordpress'
                    Contents: 'from$(Build.SourceBranchName)_wordpress.sql'

build-wordpress.yml (linked template from azure-pipelines.yaml)

stages:
  - ${{ if and(ne(parameters.replaceDomainFrom, false), ne(parameters.replaceDomainTo, false)) }}:
    - stage: build
      dependsOn: mysqlDumpFromDev
      jobs:
      - job:
        displayName: 'Prepare applikation for deployment'
        steps:
          - download: none
          - script: echo -e "\n\nData from \n\t${{ parameters.replaceDomainFrom }}\n will be transformed to: \n\t ${{ parameters.replaceDomainTo }}"

          - task: DownloadPipelineArtifact@2
            inputs:
              buildType: 'current'
              artifactName: 'sqldump_dev'
              patterns: ${{ parameters.buildFrom }}_wordpress.sql
              path: $(Build.Repository.LocalPath)/wordpress

And this is where those artifacts are staved (in a previous pipeline):

1

There are 1 best solutions below

0
On

In my opinion it seems to be a bug wit dev.azure.com and Pipelines. As If I change the pipeline not to use PublishPipelineArtifact@1 but PublishBuildArtifacts@1 the download work again:

changed pipeline

Download work

So even if MS recommend, to use PipelineArtifact instead of BuildArtifacts, you might run in same error like me... if so... give BuildArtifacts a try and it will save you days of try & error.

In my case it cost me a bunch of hours to fix!!

Downside

The downside: It's incredible slower with buildArtifacts. Is something like 28 minutes upload & 4 minutse download VS 7 seconds upload and 4 seconds download for pipelineArtifacts

I hope they will fix this bug soon!