azure-pipelines-tasks: YAML task for download artifacts does not work with variable

I have been working in Azure Devops Services. I’ve added to my azure devops pipeline step to download artifact from CI pipeline. It is working perfect, but I tried to change artifact name to variables, because this names is using in many places.

strategy:

        runOnce:

          deploy:

            steps:    
      
            - download: $(artifactPipe) 
            
              artifact: $(artifactName)

When I execute this code I receive error:

##[error]Invalid hex string #/11700000/drop (Parameter ‘hex’)

I think this is a bug. I want to ask to fix this ASAP. Because it is block our production pipeline. Thanks in advance.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I have the same issue, but since the bug seems to stay unfixed, I decided to share my workaround. I use the DownloadPipelineArtifact@2 task and provide resource information via variables.

This is how my template is setup.

resources:
  pipelines:
  - pipeline: MyProjectPipeline
    source: MyProject

parameters:
- name: DataSource
  default: 'current'
  values:
    - 'current'
    - 'MyProjectPipeline'

This is what I want to do:

# this does not work because there is a variable name in artifact
  - download: ${{ parameters.DataSource}}
    artifact: '$(NameOfArtifactProvidedByMyProjectPipeline)'

Instead i do this:

  - ${{ if eq(parameters.DataSource, 'current') }}:
    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'current'
        artifactName: '$(NameOfArtifactProvidedByMyProjectPipeline)'
    
  - ${{ if eq(parameters.DataSource, 'MyProjectPipeline') }}:
    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'specific'
        project: '$(resources.pipeline.MyProjectPipeline.projectID)'
        definition: '$(resources.pipeline.MyProjectPipeline.pipelineID)'
        buildVersionToDownload: 'specific'
        pipelineId: '$(resources.pipeline.MyProjectPipeline.runID)'
        artifactName: '$(NameOfArtifactProvidedByMyProjectPipeline)'

@titans2016 do you use PublishPipelinesArtifacts task to publish artifacts? Looks like original artifact was generated by publish build artifacts task - so some field has wrong format, which causes this issue. If you published it via PublishBuildArtifacts tasks - it would be more reliable to download it via DownloadBuildArtifacts task.