How do I delete a specific Jfrog build with the cli (and its corresponding artifact) - artifactory

I'm confused about how to perform this operation, it almost seems like it's not supported. Looking at the docs I see no examples for deleting a specific build version: https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-DiscardingOldBuildsfromArtifactory
I use build discarding now, but that's not what this is. I want to remove a specific build version and its corresponding artifact, not use --max-days or --max-builds. How is this possible? I want to delete the build AND the artifact.
I use Jfrog to host an internal helm repo, helm has no built-in command to delete a chart from a remote repo.

For deleting a specific artifact of a build using jfrog cli run
jfrog rt delete --build build-name/build-number
Parse --dry-run to know which artifacts would have been deleted.
More info on CLIforJFrogArtifactory-DeletingFile.

Related

Configuring Maven when using JFrog CLI

When trying to run a build of a maven application using jfrog CLI, one of the prerequisite steps is to run
jf mvn-config
When we run it manually on a server, it has an interactive step to configure the resolution for release dependencies (tab and select)
I am wondering is there a way to feed in the config parameters as CLI arguments to jf mvn-config so that we can set the properties programmatically for the repository?
I believe this comment from the JFrog CLI Github page and the --global attribute option described here would be an useful information. It is important to note that the configuration set up using jf mvn-config may override the global settings.

Deploy debian package for multiple distros into Jfrog Artifactory?

What is the right procedure to deploy a debian package built for different distros into the same Jfrog debian artifactory repo?
Just uploading to the same path, but with different deb.distribution properties does not work, they all get uploaded to the same place and clobber the previous upload.
Including the distribution name into the package name is ugly, but would of course work. Is there a better way?
You simply post the different debian to different locations within the Jfrog artifactory repository. The trick is that the repository layout has nothing to do with the aptitude API, which retrieves debians regardless of their location according to the requested metadata (deb.distribution, deb.version etc).

JFrog cli deploy a single file to artifactory target directory

I need to delete old snapshots from the Artifactory. For cleanup we recently configured Max Unique Snapshots to 5, but the garbage collector only deletes the old snapshots when a new snapshot is deployed.
How do I deploy a single file to the Artifactory using the JFrog-cli? I am unsure of which command to use from their documentation. https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory
You can deploy a single file to Artifactory using the CLI with the upload command, for example:
jfrog rt u froggy.tgz my-local-repo
For additional documentation about the upload command take a look at the JFrog CLI documentation

Cleanup old artifacts from Jfrog artifactory OSS

I'm using Jfrog artifactory OSS version 5. I can see my snapshot repository is too huge and I want to remove unwanted artifacts from snapshot repository.
I want to remove all artifacts which were not downloaded during last 6 months.
I tried below method, but its not working seems because of I'm using OSS version.
curl -X POST -v -u user:'password' "http://<my artifactory url>/artifactory/api/execute/cleanup?params=months=6|repos=snapshots|dryRun|paceTimeMS=2000"
Is there any other way that I can perform my task and if somebody can help me to do this, it would be really appreciated.
Thank You
You can use JFrog's CLI to delete items based on AQL queries.
For example, you can use an AQL query like:
items.find({"created" : {"$before" : "6mo"}})
To find all items that were created over 6 month ago.
You can then use your AQL as part of a spec file for deleting items and artifacts, using the JFrog CLI.
To read more about the AQL Time Operators
To read more about CLI and File Specs
items.find (
{
"repo":"snapshots",
"stat.downloads":{"$eq":null}
}
)
This will search for file which have not been downloaded ever, under repository name "snapshots"

Is there a URL for the latest snapshot for an artifact in Artifactory?

I would like to make a permalink to the latest snapshot version of an artifact in Artifactory. If we are on 1.0-SNAPSHOT, I would like a URL that downloads the latest 1.0-SNAPSHOT JAR. I can find the latest artifact by locating the artifact on our server at http://hostname/artifactory/libs-snapshot/groupId/artifactId/1.0-SNAPSHOT/. Other than checking the timestamps, I can figure out which one if the latest by opening maven-metadata.xml and matching metadata/versioning/snapshot timestamp and buildNumber with a JAR in the same directory. This could be scripted, but ideally Artifactory already has a way to construct a permalink in this manner. Does Artifactory provide such a URL?
Doing the normal query for the entry with artifactId-1.0-SNAPSHOT.jar in the URL name should return automatically the latest snapshot.
See the doc here
One thing: This is base either on the latest creation date if no pom present, or latest creation of the pom if there are some. Mixing pom and non-pom deployment may results in strange results!
I tried using shell script and it worked for me.
Step1: Get an encrypted password for your user account by clicking on user name or create a common user. Go to using your secure password section in the following link
http://www.jfrog.com/confluence/display/RTF/Centrally+Secure+Passwords
Step 2: In your local machine create a temp folder and type this curl(may be wget for windows) command:
curl -o tmp/foo.jar --user <username>:<encrypted_password> <artifactory_url>/list/libs-snapshot-local/com/search/foo/1.0/foo-1.0-SNAPSHOT.JAR
Your foo.jar in tmp folder is latest version. If we dont give timestamp as like above, it will download latest artifact in that version. Hope this helps!
This might be helpful:
How to download the latest artifact from Artifactory repository?
Although there is no permalink ability in the free version of Artifactory, it can be scripted easily as you suggest. I have provided a quick script to do that in the referenced question.
Hope it helps.
Another portable option is to use the maven command line:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version] -Ddest=[dest file]
This works for me (no search API, just direct artifact URL):
curl -O -J --user <username>:<encrypted_password> http://hostname/artifactory/libs-snapshot/groupId/artifactId/1.0-SNAPSHOT/artifactId-1.0-SNAPSHOT.jar
Basically using 1.0-SNAPSHOT in the artifact name downloads the latest version of 1.0-SNAPSHOT snapshot.

Resources