简体   繁体   中英

Artifactory: jfrog CLI command to get full path of a specific artifact

I'm trying to improve the development processes in my area by developing some magical python scripts to take care of build and deployment processes. I'm using Teamcity and Artifactory to build and manage artifacts.

One of the step in the process is to get the artifact URL of the latest deployed build artifact from Artifactory. I wanted to create a CLI command that could take some parameters like repository name, name/pattern of artifact etc. and churn out the full path of the artifact.

Wondering if someone has used jfrog CLI before and can help me create such command?

I'm sharing few sample artifacts below for reference:

https://artifactory-1.dts.fm.abcgrp.net/artifactory/fsap-staticfile-libs-releases-local/fsap/aap-aml-ui/2.2.1/aap-aml-ui-2.2.1-dist.zip

https://artifactory-1.dts.fm.abcgrp.net/artifactory/fsap-libs-snapshots-local/com/abc/fsap/aap-aml-msvc/0.0.0-feature-FSAP-9787-SNAPSHOT/aap-aml-msvc-0.0.0-feature-FSAP-9787-20200807.134731-5-dist.jar

https://artifactory-1.dts.fm.abcgrp.net/artifactory/fsap-libs-snapshots-local/com/abc/fsap/aap-lime-msvc/0.0.0-development-SNAPSHOT/aap-lime-msvc-0.0.0-development-20200717.061034-4-dist.jar

You can make use of the search command which comes with JFrog CLI to get all the files listed. However, it will be listing the whole information about all the artifacts which satisfy the requirement and also will be listing out the repo path in Artifactory so I hope for your particular use case you might have to come up with some filters to do the 2 operations.

  1. Filter only the path value from the search command
  2. Append JFrog base URL to each line.

One of the quick way to implement this would be to use simple jq filter like below:

jfrog rt s "myrepo/*.zip" | grep -v "\[INFO\]" | jq -rj '.[] | "https://myartifactory.com/artifactory/", .path, "\n"'

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