Azure DevOps、Release Pipeline、Powershell 任务:提取 .tar.gz 即使在操作成功后也显示为失败
Azure DevOps, Release Pipeline, Powershell task: Extracting .tar.gz shown as failure even after operation succeeds
对于我的 Azure DevOps 发布管道,我获取构建工件(从 python 存储库生成)并像这样提取其内容:
# 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
我可以在日志中看到 tar
能够从工件中提取内容。打印 foo.txt 的 type
命令也成功了。
但是,我看到了这个错误:
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 >>>
我做错了什么?感觉整个发布管道都会很好地工作,如果不是因为这个误报错误的话。因此无法执行此阶段的进一步任务。
我没有你的文件,所以无法测试它,但你可以尝试使用内置任务:
# 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
我以这种方式测试了您创建工件的方法:
#
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'
然后在发布管道中使用它:
# 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)'
并且有效。所以它可能与您的 tar.gz
文件有关。能不能下载下来在本地测试一下
对于我的 Azure DevOps 发布管道,我获取构建工件(从 python 存储库生成)并像这样提取其内容:
# 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
我可以在日志中看到 tar
能够从工件中提取内容。打印 foo.txt 的 type
命令也成功了。
但是,我看到了这个错误:
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 >>>
我做错了什么?感觉整个发布管道都会很好地工作,如果不是因为这个误报错误的话。因此无法执行此阶段的进一步任务。
我没有你的文件,所以无法测试它,但你可以尝试使用内置任务:
# 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
我以这种方式测试了您创建工件的方法:
#
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'
然后在发布管道中使用它:
# 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)'
并且有效。所以它可能与您的 tar.gz
文件有关。能不能下载下来在本地测试一下