Why can't Artifactory download requested artifact? - maven

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

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

Artifactory - randomly add datetime to artifact name

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.

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.

Maven + Hudson + Nexus: Access to SNAPSHOT Build Number

Now that Maven3 has dropped support for setting uniqueVersion=false on deployment, I'm running into an issue. I have Hudson do an automatic deployment of my SNAPSHOT build to my Nexus repository manager. The resulting SNAPSHOT artifact looks like blah-0.0.1-20110517.233746-1.jar. Note the unique SNAPSHOT build id. The trick is that I'd link to that jar in my site documentation, but I'm not sure how to inject that snapshot build number into the docs. Perhaps there is a way to have Maven or Hudson or Nexus create a symlink on deployment from blah-0.0.1.jar => blah-0.0.1-20110517.233746-1.jar?
Ok, mod me down, but I think I found an answer to my own question. I'm posting here in case anyone else finds it useful.
It turns out the Nexus REST api has the ability to automatically retrieve the latest SNAPSHOT build of an artifact, which is exactly the functionality I needed. For more info, see:
https://docs.sonatype.com/display/SPRTNXOSS/Nexus+FAQ#NexusFAQ-Q.HowcanIretrieveasnapshotifIdon%27tknowtheexactfilename%3F

Resources