简体   繁体   English

Jenkins人工插件-识别文件不存在

[英]Jenkins artifactory plugin - identify that files are not there

I'm using Jenkins Artifactory plugin to publish artifacts as well as download required artifacts. 我正在使用Jenkins Artifactory插件来发布工件以及下载所需的工件。 When downloading artifacts, what needs to be downloaded is determined dynamically while the Jenkins pipeline is executing. 在下载工件时,需要在Jenkins管道执行时动态确定需要下载的内容。

If the artifacts that need to be downloaded are not there in artifactory, I want to abort the pipeline with a corresponding error message. 如果需要下载的工件不在工件中,那么我想中止管道并显示相应的错误消息。 Unfortunately, I can't figure out how to determine presence or absence of files. 不幸的是,我不知道如何确定文件的存在与否。 Artifactory.download call does not throw any exceptions if requested files are not there and doesn't return any meaningful information. 如果请求的文件不存在, Artifactory.download调用不会引发任何异常,并且不会返回任何有意义的信息。

Of course, I can always check whether or not files exist after the download, but I was hoping for some "native" way. 当然,下载后我总是可以检查文件是否存在,但是我希望有某种“本机”方式。 So, how can I verify after the download call whether or not my requested artifacts have been downloaded? 因此,在download调用之后如何验证我是否download我所请求的工件?

Actually, there are 2 options: 实际上,有两种选择:

Option 1: Use the failNoOp flag. 选项1:使用failNoOp标志。 It'll fail your pipeline in case of 0 downloads: 如果下载0,它将使您的管道失败:

server.download spec: downloadSpec, failNoOp: true

Option 2: In the latest Jenkins Artifactory plugin v3.2.0 there is a new feature to list downloaded/uploaded files: 选项2:在最新的Jenkins Artifactory插件v3.2.0中,有一项新功能可以列出下载/上传的文件:

def buildInfo = Artifactory.newBuildInfo()
server.download spec: downloadSpec, buildInfo: buildInfo
if (buildInfo.getDependencies().size() == 0) {
 // Do your magic
}

More information can be found in the documentation . 可以在文档中找到更多信息。

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

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