Artifactory - randomly add datetime to artifact name - maven

From Azure CI pipeline I can see that before the build/artifact upload to Artifactory, the artifact id is
my-app-0.0.1-SNAPSHOT.jar
however after Artifactory upload, it becomes
my-app-0.0.1-20211006.161121-1.jar
But another Java project don't have such behavior hence no extra data/timestamp in the artifact name.
I assume the pipeline only upload the jar file without check the pom.xml, so what can be the cause of such difference in the naming convension.

When SNAPSHOTs are uploaded to Nexus or Artifactory, the suffix SNAPSHOT is automatically replaced by a timestamp and a number.
This is perfectly normal and nothing to worry about.

Related

What configuration or variable caused Aritfactory to replace "-SNAPSHOT" with timestamp

Current CI pipeline can push artifact to Artifactory. I can see one of the snapshot artifact was built with suffix -SNAPSHOT like
my.first.app-0.0.1.SNAPSHOT.jar
across the pipeline, until it uploaded to Artifactory that the file name changed to
my.first.app-0.0.1-20211007.010722-1.jar
However there is another application
my.second.app-0.0.1.SNAPSHOT.jar
was processed by the same pipeline and after uploaded to Artifactory the file name stayed the same
my.second.app-0.0.1.SNAPSHOT.jar
So just wondering what variable caused the difference in behavior. My goald is to avoid this timestamp however I have no control in Artifactory settings and based on above observation, seems not an issue with repository level settings.
This behavior is a maven feature and not related to artifactory.
See a similar question on this: Why the snapshot name always has date in its jar file name ? How to remove it

Custom build tagging with Jenkins, Artifactory, Maven

I'm working on a strategy to tag builds in my continuous integration and delivery pipeline. When a fresh build is produced it then goes through multiple stages of testing; after each stage I would like to tag the build. My idea was to expand on the standard Maven system, so an example would be:
my-artifact-1.0-SNAPSHOT.jar
my-artifact-1.0-PASSED_TESTS_1.jar
my-artifact-1.0-PASSED_TESTS_2.jar
...
my-artifact-1.0-RELEASE.jar
As a build passes each stage its tag, which is part of its name/version, gets updated. Eventually, after all testing stages the build is tagged as releasable with RELEASE.
I'm using a Jenkins server and storing artifacts on Artifactory (non-Pro) in Maven repositories. My plan is to use separate Maven repositories for each tag type above, and to move an artifact from one to the other as its tag is updated.
My pseudo-code for the promotion looks like:
(1) Download artifacts that passed in Jenkins
(2) Text-replace the tag (maybe pom.xml as well?)
(3) Upload to new repository
(4) Update the associated Git commit with tag also
I'm not sure how to actually implement this cleanly - is this a common way of doing things? Am I missing something important? Can a Jenkins + Artifactory (non-Pro) + Maven (repos only, Gradle for builds) system accomplish this?
Thanks!
I can see where the idea of adding more metadata to the file names come. Usually, we don't have any other place to add this kind of information, except of the name. But with a proper artifact repository manager (as Artifactory), you don't need it anymore. You can attach any metadata to the artifacts in the repository manager, and then manipulate (e.g. promote) the artifacts based on those properties.
Here's a screencast showing what it takes to add this kind of metadata to the artifacts, and how to promote artifacts based on it.

How to preserve the timestamps generated for SNAPSHOT artifacts?

Currently a Maven build (inside Jenkins) is configured to deploy every artifact it builds (releases and snapshots) to a Nexus repository. Now I have to push some of those artifacts to application servers and thought of letting the target servers fetch them from Nexus - this is easy for releases but how can I reference the SNAPSHOT artifacts? Maven's deploy plugin adds a timestamp to make each artifact unique (which is good) but I couldn't find a way to get that generated timestamp for later use!
Quick Aside: I plan to use the promoted builds plugin to start a script on the target server(s) which then in turn ask Nexus for the new artifact to deploy.
Does anybody know how I can make Maven say the timestamp it generates? Or do I really have to parse the whole output for Uploaded: https://NEXUS_URL/content/repositories/snapshots/GROUP/ARTIFACT/VERSION/ARTIFACT-VERSION-TIMESTAMP-SUFFIX.TYPE?
As far as I know you do need to parse the output of the deploy goal.

Tagging current snapshot artifact in artifactory

I need to be able to tag the current snapshot artifact when I publish to artifactory. The reason for this is because I need to store the tag in a manifest inside the artifact.
At the time of publishing the artifact I won't know the exact timestamp as it would be stored in Artifactory
I have tagging working though it applies it to all artifacts of a certain snapshot. Not the artifact being published.
I just need to limit it to the one being published
The syntax for tagging is
Usage: PUT /api/storage/{repoKey}{itemPath}?properties=p1=v1[,v2][|p2=v3][&recursive=1]
I can't seem to be able to get more granularity than <version>-SNAPSHOT
Many thanks
That's what you need:
ivy-local/org/acme/1.0-[INTEGRATION]/acme-1.0-[INTEGRATION].jar
This is the path to latest snapshot.

Why can't Artifactory download requested artifact?

We deploy to Artifactory an artifact that has a [filename] name that gets a time stamp applied to it by Artifactory. Later in a different trunk, its build attempts to download that artifact using the same name under which it got deployed earlier. However, because of the time stamp that Artifactory applied to the file name, this subsequent build fails with a "Unable to download the artifact from any repository" error. Other than turning of Artifactory time stamping, is there a solution to this problem? Our belief was that Artifactory would be smart enough to know at least to return the latest time stamped artifact when requested.
Normally this would be a comment but since I'm lacking the rep for this I do this as answer:
For sure Artifactory should be able to handle this. Why do you think the timestamp is the problem? This is normal for snapshots and f.e. the maven-metadata.xml should indicate which is the last version.
Do you use a version range for the artifact?
its build attempts to download that artifact using the same name under which it got deployed earlier.
Do I get you right: The artifact that you describe to be deployed to Artifactory in its (own) build wants to use itself? Could you post relevant parts of your POM?
I got similar issue recently after I changed repository configuration from storing non-unique snapshots to unique snapshots. (See here)
When both unique snapshot and non-unique snapshot of the same version of an artifact exists, there will be problem to download it.
For example, in a repository if under folder /com/mycompany/test/foo/1.0.0-SNAPSHOT/ there are foo-1.0.0-SNAPSHOT.pom and foo-1.0.0-20130329-231102-1.pom, then downloading com.mycompany.test:foo:1.0.0-SNAPSHOT:pom will get error. You have to delete either the file with SNAPSHOT in name or all the files with time stamp in name.
For my case, my repository switched from storing non-unique snapshots to unique snapshots, so I should delete the *-SNAPSHOT files. I wrote a Ruby script to scan all recent deployed artifacts and try to delete the same version non-unique snapshot (-SNAPSHOT) file if any. It uses Artifactory's REST API. Here is the source: https://gist.github.com/aleung/5260512

Resources