提取文件:处理“找不到文件".警告 [英] Extract files: to process "no files were found" warning

查看:52
本文介绍了提取文件:处理“找不到文件".警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理提取文件任务找不到要提取的文件的情况?

如果没有提取文件,是否可以将提取文件任务设置为失败?这是一个示例任务

 步骤:-任务:ExtractFiles @ 1displayName:提取文件"输入:archiveFilePatterns:'$(System.ArtifactsDirectory)\ *.zip'destinationFolder:'$(System.ArtifactsDirectory)\ bin' 

如果没有找到文件,它不会失败

2020-10-01T14:25:23.1175947Z搜索:目录下的* .zip:E:\ ba \ n1_work \ r16 \ a
2020-10-01T14:25:23.1287445Z找到:0个要提取的文件:

然后执行ftp上传任务

2020-10-01T14:25:36.4142531Z ## [警告]找不到任何要上传的文件

发布管道很简单

  • 提取文件
  • 停止Azure应用服务
  • 通过ftp上传文件
  • 启动Azure应用服务

我添加了powershell脚本来检查是否提取了文件

  if(-非(Test-path $ {System.ArtifactsDirectory)\ bin \ *)){引发New-Object System.ArgumentException(未提取文件")} 

但想知道如果没有提取或上传任何内容,是否可能使ExtractFiles @ 1或FtpUpload @ 2任务失败?

致谢

解决方案

市场上还有其他可用的任务,您可以用来解压缩软件包.您可以尝试使用

对于FTP上传,您可以签出 FTP上载器任务.

How do you handle cases when the Extract files task does not find files to extract ?

Is it possible to set the Extract files task to fail if there were no files extracted ? Here is a sample task

steps:
- task: ExtractFiles@1
  displayName: 'Extract files '
  inputs:
    archiveFilePatterns: '$(System.ArtifactsDirectory)\*.zip'
    destinationFolder: '$(System.ArtifactsDirectory)\bin'

it does not fail if no file was found however

2020-10-01T14:25:23.1175947Z Searching for: *.zip under directory: E:\ba\n1_work\r16\a
2020-10-01T14:25:23.1287445Z Found: 0 files to extract:

and then a ftp upload task does nothing

2020-10-01T14:25:36.4142531Z ##[warning]Could not find any files to upload

The release pipeline is simple like

  • extract files
  • stop azure app service
  • upload files by ftp
  • start azure app service

I've added the powershell script to check for files were extracted

if (-not (Test-path $(System.ArtifactsDirectory)\bin\*) )
{
Throw New-Object System.ArgumentException("no files were extracted")
}

but would like to know is it possible to make ExtractFiles@1 or FtpUpload@2 tasks to fail if there was nothing extracted or uploaded ?

Regards

解决方案

There are other tasks that are available in the marketplace you can use to unzip the package. You can try using Unzip Task or Zip and unzip directory build task in stead of using Extract files task.

I tested with Unzip Task and Zip and unzip directory build task. They both work greatly and failed as expected when no file is found to unzip. See below

And for FTP upload, you can check out FTP Uploader task.

这篇关于提取文件:处理“找不到文件".警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆