Warm tip: This article is reproduced from serverfault.com, please click

How to add a single file to an existing snapshot timestamp version in Sonatype Nexus

发布于 2020-12-21 17:57:08

I am working on a CI/CD pipeline for Jenkins, which is used by various projects. All projects use Maven and deploy their snapshot and release versions to a given Artifact Repository.

In the pipeline I also create a file and deploy it via mvn deploy:deploy-file with the same snapshot version, e.g. 1.2.3-SNAPSHOT, to the used repository. Hence the actual deployment of the project was done before, a new timestamped snapshot version is created.

In the used repository, it looks like this:

─┬─ my-artifact
 │  ├─ 1.2.3-SNAPSHOT
 │  ├─ 1.2.3-SNAPSHOT-20201215.123453-1
 │  │  └ ...
 │  ├─ 1.2.3-SNAPSHOT-20201215.123463-2
 │  │  ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123463-2.jar
 │  │  ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123463-2.jar.md5
 │  │  ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123463-2.jar.sha1
 │  │  ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123463-2.pom
 │  │  ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123463-2.pom.md5
 │  │  └─ my-artifact-1.2.3-SNAPSHOT-20201215.123463-2.pom.sha1
 │  └── 1.2.3-SNAPSHOT-20201215.123473-3
 │      ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123473-3-cyclonedx.xml
 │      ├─ my-artifact-1.2.3-SNAPSHOT-20201215.123473-3-cyclonedx.xml.md5
 │      └─ my-artifact-1.2.3-SNAPSHOT-20201215.123473-3-cyclonedx.xml.sha1

As you can see, the snapshot version 1.2.3-SNAPSHOT-20201215.123473-3, uploaded by my pipeline code, has a totally different content then the previous version. Any Maven project requesting the latest snapshot version will fail to find the jar file, as the latest snapshot contains only the XML document.

Is there a way to deploy, or better to say, to attach an artifact to an existing timestamped snapshot version? I am afraid not, but I would like to validate my thoughts before choosing a totally different approah.

Within the pipeline I can do everything, execept modifying the POM of Maven project. Changing the Maven project is not possible, because there are many of them an the features I have to implement come from different stakeholders.

Questioner
Oliver
Viewed
0
J Fabian Meier 2020-12-22 03:31:24

khmarbaise is right.

You need to change the POM.

If the file should be part of the SNAPSHOT, it must be part of the Maven build.

If it has nothing to do with the build, you might better place it somewhere else.