0

How to download previous build version ( a.b.c.d-1 ) if requested version ( a.b.c.d ) does not exist in artifactory.

Using Artiffactory plugin in Jenkins pipeline.

Javier C.
  • 7,859
  • 5
  • 41
  • 53
user1316502
  • 809
  • 2
  • 10
  • 21
  • Why not resolving the latest version in case that the requested version doesn't exist? – Ariel Oct 24 '17 at 04:36
  • can you use jfrog cli search command inside shell for your pipeline, if exists, then download, otherwise try previous version – Larry Cai Oct 25 '17 at 19:05

2 Answers2

0

You can use Jfrog CLI in your pipeline to do this, you don't need Jenkins Artifactory Plugin.

You can define your pipeline to download the artifact version that you want and if you have an exception (don't exist) you can download another version.

The command for donwload an antifact is:

jfrog rt dl my-local-repo/your-artifact-a.b.c.d.zip

You can catch exceptions in your pipeline with this code:

stage('Your stage') {
     try {

       //Your code for Jfrog CLI
       jfrog rt dl my-local-repo/your-artifact-a.b.c.d.zip

    } catch (Exception err) {

       //Your additional code

    }
 }

You can viisit the official page of Jfrog CLI: Jfrog CLI Downloading files

Javier C.
  • 7,859
  • 5
  • 41
  • 53
  • This Exception based approach doesn't look reliant to me as we would need to know exact exception type when file is not found in Arti. I don't want to overwrite other important Exceptions they might signal of problems while I just want to simulate expected behavior. I am looking for a way to get this kind of info from Arti using plugin not CLI. – user1316502 Oct 24 '17 at 10:10
  • The Jfrog CLI launch a not generic exception but I don't know the type of this exception. You only need to change catch (Exception err) for the type of exception that launch Jfrog CLI. – Javier C. Oct 24 '17 at 10:14
0

The only working version so far is to try to download server.download(downloadSpec) each artifact in a loop ( a.b.c.d-- ) and check if files appeared in the file system. Still looking for more elegant solution.

user1316502
  • 809
  • 2
  • 10
  • 21