繁体   English   中英

Azure DevOps、发布管道、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 

我以这种方式测试了您创建工件的方法:

# https://stackoverflow.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'

然后在发布管道中使用它:


# 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文件有关。 能不能下载下来本地测试一下。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM