Maven Deploy : How to get snapsnot version

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Maven Deploy : How to get snapsnot version



Is there a way to capture the actual snapshot version and let's say output it to file?


[INFO] Uploading to nexus: https://xxxx/repository/xxx/xxx/0.0.1-SNAPSHOT/xxx-0.0.1-2
0180809.182425-2.pom



I can see it in the console output, but I am looking for a reliable way to extract it and use it for some post processing, by example, assemble it in a docker image and deploy it.





To put that into a docker image you could use dmp.fabric8.io ... for recording it: github.com/khmarbaise/deployment-recorder-extension ?
– khmarbaise
Aug 9 at 18:59





You could also consider github.com/ktoso/maven-git-commit-id-plugin as an alternative way of recording what produced the image. It may be worth thinking about how long your nexus keeps snapshots for and whether you could link back from snapshot to source code.
– Ryan Dawson
Aug 9 at 20:40




2 Answers
2



As khmarbaise suggests, you could get the snapshot info from a Maven extension such as https://github.com/khmarbaise/deployment-recorder-extension Recording a timestamp would also give you a good approximation as normally snapshot ids are timestamp-based.



It is worth being cautious about how much value you put on the snapshot for traceability as snapshots are typically not retained in nexus indefinitely. If you're looking to trace the code in a docker image that is itself using a latest/snapshot tag then you might find more value in the last git commit (https://github.com/ktoso/maven-git-commit-id-plugin). If the image will have its own dedicated tag then it would be advisable to also create a corresponding tag in the source code.



This is very difficult to achieve during the build process as the deploy-plugin uses the very timestamp of the deployment to version the artifact and it will not share that information other than in the log. That means that any timestamp that you catch during the build process will be before that timstamp and will therefore not be suitable.



To solve the issue, you either need to parse the command output or use external tools:


maven-metadata






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard