Get maven deployment URL during/after deployment
Asked Answered
C

1

6

I have a Java project. It has a pom.xml set up and I use mvn deploy to deploy new artifacts to an internal company Nexus. And everything is working fine.

But... I'm working on integrating this application in a CI/CD system. So, basically what I need is to programmatically / automatically know where this artifact was deployed (the exact Nexus URL of the artifact) so I can include this as input for the next step of the CI/CD system.

I know this usually isn't needed when working with Maven. But what can I say, I need this URL to appear on some web page which shows this artifact, along with some other info related to it, like which tests were run on it, who created it, when, on top of which commit of which repository it was built etc...

So... Is there a nice, clean way for me to get this info, apart from the hackish way of manually parsing the pom.xml file to try to recreate the URL. Something like mvn give-me-the-url-to-which-you-would-deploy-if-i-were-to-run-deploy. :)

Cacilia answered 17/10, 2017 at 11:15 Comment(3)
hi @Cacilia did you find any solutions to this problem?Temperate
@Temperate unfortunately no. :( don't remember how exactly i progressed with this problem, most probably something related to the only answer given below.Cacilia
same problem here.. cannot find any solutionHydrolysis
B
5

A direct, but a little bit hacky way would be to read the Maven log file. It contains lines like

Uploaded: http://ik-re1.continentale.loc:8082/nexus/content/repositories/snapshots/de/continentale/spu/rrep-pjava-index/2.3.4-SNAPSHOT/rrp-pjav-index-2.3.4-20170901.115031-18-sources.jar (202 KB at 2459.3 KB/sec)

These lines tell you the exact URLs, but you need to parse a text file.

Ballot answered 17/10, 2017 at 12:49 Comment(1)
Yes, I did it in the end like this, using tee to redirect Maven's output to a log file. But still this is a hackish solution. But since there doesn't seem to be a better, proper solution, this will have to do. Thanks.Cacilia

© 2022 - 2024 — McMap. All rights reserved.