Jenkins检查文件存在于zip文件中



是否有一种方法可以在不解压缩的情况下检查zip文件中是否存在文件?我在用Artifactory。如果使用curl就不能。可以给我一些建议吗?

I tried below

sh(script: "curl -o /dev/null -sf <antifactory url>")

this总是返回successandbelow

unzip -l <file.zip> | grep -q <file name>

这个需要安装unzip

从Artifactory 7.15.3中提到的这个页面存档搜索是默认禁用的。你能否确认你的版本是否高于此。如果是,您可以通过导航到Admin>Artifactory祝辞启用存档搜索并启用此复选框。但是请注意,如果我们启用此功能,它会为每个存档文件持续向数据库写入大量信息,并可能影响性能。

稍后您可以搜索zip文件中的项目。下面是一个示例命令,我在curl中搜索zip中的.class文件。您可以在Jenkis中选择类似的选项。

$ curl -uadmin:password -X GET "http://localhost:8082/artifactory/api/search/archive?name=*.class&repos=test" -H "Content-type: application/json"

您可以使用bash命令unzipgrep

unzip -l my_file.zip | grep -q file_to_search
# Example 
$ unzip -l 99bottles.zip | grep -q 99bottles.pdf && echo $?
0

注:如果zip包含目录结构,那么grep使用文件名

的完整路径

最新更新