简体   繁体   中英

Jenkins artifactory plugin - identify that files are not there

I'm using Jenkins Artifactory plugin to publish artifacts as well as download required artifacts. When downloading artifacts, what needs to be downloaded is determined dynamically while the Jenkins pipeline is executing.

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.

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?

Actually, there are 2 options:

Option 1: Use the failNoOp flag. It'll fail your pipeline in case of 0 downloads:

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:

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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