1
votes

For my Azure DevOps release pipeline, I get the build artifact (generated from a python repo) and extract its contents like this:

# Write your PowerShell commands here.

Write-Host "Extracting sources"

cp $(System.DefaultWorkingDirectory)/_repo-master-pipeline/dist/repo-1.0.0.tar.gz .

tar xvzf repo-1.0.0.tar.gz

type repo-1.0.0/foo.txt

I can see in the logs that tar is able to extract contents from the artifact. The type command which prints foo.txt succeeds too. But, I am seeing this error:

2020-11-06T10:05:32.3917349Z Extracting sources
2020-11-06T10:05:32.6074421Z ##[error]x repo-1.0.0/
<<< some lines from the tar command are printed here showing successful extraction >>>

What could I be doing wrong? Feels like the entire release pipeline will work great, if not for this false-positive error. Further tasks in this stage cannot be executed because of this.

1
In task details, in Control Options you have setting continue on error. Please mark it to check if further steps works as expected.Krzysztof Madej
If I select the continue on error control option, the release pipeline will progress even if there really is an error. This is something I want to avoidOrange
I know. I just wanted to know if further steps works.Krzysztof Madej

1 Answers

0
votes

I'm can't test it as I don't have your file, but you can try to use built in task:

# Extract files
# Extract a variety of archive and compression files such as .7z, .rar, .tar.gz, and .zip
- task: ExtractFiles@1
  inputs:
    #archiveFilePatterns: '**/*.zip' 
    destinationFolder: 
    #cleanDestinationFolder: true 

I tested your approach creating artifact in this way:

# https://stackguides.com/questions/64712778/azure-devops-release-pipeline-powershell-task-extracting-tar-gz-shown-as-fai/64713036#64713036

trigger: none
pr: none

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: |
    ls
    tar -czvf archive.tgz *.yaml
    echo "here"
    cp archive.tgz '$(Build.ArtifactStagingDirectory)'
  displayName: 'Run a multi-line script'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

and then consuming it in release pipeline:


# Write your PowerShell commands here.

Write-Host "Extracting sources"

cp '$(System.DefaultWorkingDirectory)/_kmadof.devops-manual (42)/drop/archive.tgz' .

tar xvzf archive.tgz

ls _'kmadof.devops-manual (42)'

and it works. So it could be sth with your tar.gz file. Can you download it and test it locally.