Artifactory REST API Latest Release Version - artifactory

I'm trying to develop a script to query Artifactory for artifact details. The AQL api does the trick for providing me SHA1, SIZE and location. However I need to restrict this information to a specific release. Does Artifactory provide an API endpoint that will return the latest release version for a specific repo? I've already looked over the Artifact Latest Version Search Based on Layout API and while this will work I would need to provide a specific artifact to key off of.
Basically I'm trying to gather a complete list of artifact details from a given repo based on latest release. I'm after the sha1, size, and name of a given artifact for a specific release.

Related

How can R script determine it's version, from a GitHub release tag?

I have an R project that generates some Solr and RDF output. The project is in a GitHub repo, and I have a pre-release tagged 1.0.0
My team has decided that any knowledge artifacts we create should have an internal indication of the version of the software that created them.
Currently, I manually enter the release tag into a JSON configuration file after manually/interactively making the release on the GitHub website.
Could I either
automatically enter the release number into the config file when the release is built
automatically determine the release version when running the R scripts
And are either of those approaches good ideas? A user could theoretically make local changes to the R code and get out of sync with the cited release, right?

Artifactory Cloud - How to copy an artifact without messing up the repo path in the module

My build pipeline is uploading a multi-module Maven project to an Artifactory repository repo1. At the very end of the pipeline (and for certain conditions), there is a step that will copy one single artifact from repo1 to repo2. I'm using the REST API: $(ARTIFACTORY_URL)/api/copy/repo1/org/sonarsource/sonarlint/eclipse/org.sonarlint.eclipse.site/{version}/org.sonarlint.eclipse.site-{version}.zip?to=/repo2/org.sonarlint.eclipse.site-latest.zip&suppressLayouts=1
This works fine, but then I noticed that when looking at the build's published modules in the build details, in front of the artifact, the repo path is now pointing to repo2/org.sonarlint.eclipse.site-latest.zip. When browsing the repo1 tree, I can see that org.sonarlint.eclipse.site-{version}.zip is still there.
Then I tried to promote the build, but this fails. The zip is not promoted to the final repository. I found this in logs:
2020-06-12 07:56:10,266 [http-nio-8082-exec-3579] [WARN ] (o.a.a.l.t.PathTranslationHelper:68) - Unable to translate path 'org.sonarlint.eclipse.site-latest.zip': does not represent a valid module path within the source.
2020-06-12 07:56:10,895 [http-nio-8082-exec-3579] [INFO ] (o.a.b.BuildPromotionHelper:214) - Skipping promotion status update: item promotion was completed with errors and warnings.
Question: shouldn't the copy operation preserve the repo path of the copied artifact? Why pointing to the new copy? Or at least, shouldn't the promote operation be smart enough to deal with this?
With the help of JFrog support, we managed to get rid of this issue. When using the promote REST API, we had to specify the sourceRepo parameter .
Long story:
As you can see based on this KB article , once a Build Promotion is triggered, Artifactory will first search for a list of artifacts it should promote. It will search based on the SHA1 values from the Build-info JSON, and the build.name & build.number properties.
Since copied artifacts have the same SHA1 (they are basically symlink), the promote will randomly take the artifact from any of the two repos where the copy exists. Specifying the sourceRepo parameter to the build promotion step will force it to only consider this repo, and in my case that fixed the issue.

Unique link to an artifact deployed to JFrog Artifactory

I'm a new Artifactory user. My company just setup Artifactory v6.5.2 and I'm looking to use is for managing software deployed for our production team. What I need is a download link that will get documented in our product management system that directly points to the exact file that Software deployed for Production to use. I was anticipating this would look like this:
https://artifactory.mycompany.com/artifactory/myrepo/mymodule/mypkgfile_v1_b30b890becfb4a02510ed12a7283c676.tgz
I'm not seeing that Artifactory can do this for me. What I see is I can do this:
http://artifactory.mycompany.com/artifactory/myrepo/mymodule/mypkgfile_v1.tgz
However if another artifact is deployed with the same name, it's not reflected in the download link. This means that the link could return different results.
Am I missing something or am I asking Artifactory do something it's not intended to do?
Artifactory returns the URL based on on the filename and the path (as any web server would do). Here are two options to achieve what you need:
Name the artifacts uniquely (timestamps are the simplest). Instead of naming the artifact mypkgfile_v1.tgz, name it mypkgfile_v1-1553038888.tgz (I used the Unix Epoch time, but everything unique enough will do).
This one is more evolved but doesn't require you to change the naming scheme.
First, configure a custom repository layout to match your versioning.
Once you've done that, every time you deploy an artifact, attach a unique identifier to the artifact as property during deployment (using matrix params, for example), deploying your artifact as mypkgfile_v1;timestamp=1553038888.
On the revrieval, use the token for the latest release together with the timestamp you need as a matrix param:mypkgfile_v[RELEASE];timestamp=1553038888

Jfrog Artifactory REST API Search for a latest version of an artifact

I am trying to retrieve the latest version of an artifact with the following query
http://artifactory_domain/artifactory/api/search/latestVersion?g=groupId&a=artifactId&v=0.101.1&repos=repository_on_artifactory
Where :
artifactory_domain - domain name of your artifactory.
groupId - you can find it Artifact Repository Browser, please, look into a screen shot.
artifactId -you can find it Artifact Repository Browser, please, look into a screenshot.
Repo name where artifact persists.
which is assembled in accordance with the following documentation https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ArtifactLatestVersionSearchBasedonLayout
However, it returns lastest in accordance with the alphabetical order.
For example:
0.101.1
0.101.11
0.101.2
The query returns 0.101.2 despite the fact that there is version 0.101.11 already.
Is there any flag/option to retrieve the latest version based on the created date?
I found answer by myself in documentation:
To change the retrieve latest behavior to retrieve the latest version based on the created date you can add the following flag to
$ARTIFACTORY_HOME/etc/artifactory.system.properties
and add the following flag
artifactory.request.searchLatestReleaseByDateCreated=true
and restart Artifactory service

Artifactory: symlink or aliasing an Artifact URL?

I realize that the Artifactory support team reads these SO posts, so my question is either a regular question or a feature request.
I want to programmatically update various artifacts and when my operations complete (copies, writes, moves, deletes), create an alias/symlink to the new/updated artifact URLs.
For example, I would like to have a "latest" link which always points to the latest build for a number of different artifacts: Java, yum, Python and generic binaries, that is, native executables that do not use pypy/Maven/yum toolsets.
I don't see a way to do this and if that is the case, I'd like to request this feature in a new version of Artifactory.

Resources