Reputation: 13516
I'm probably approaching the problem all wrong, but here goes...
We want to implement a development
-> releases/x.y.z
-> master
workflow using Gitlab and Nexus. The artifacts should be labelled x.y.z-SNAPSHOT
, x.y.z-rc
and x.y.z
respectively.
In the ci-build.yml
, I have tried to modify the POM depending on the current branch so as to create the correctly labelled artifacts. The problem is obviously that the change will be one commit ahead of the current build commit and the POM used in the build has the original version.
e.g.
ci-build
, is modified to 2.3.4-rc and is committed and pushed to gitMy question here is the following:
Can I modify the POM and use the updated POM in all following stages of the ci-build
?
(I don't feel that this is the correct procedure, but it is what my team-leader has requested so I'm trying to implement it...)
Upvotes: 3
Views: 7150
Reputation: 13516
My solution was to avoid commits altogether and use the strategy described in https://maven.apache.org/maven-ci-friendly.html.
This defines a new property, revision
, which can be set using a maven parameter, -Drevision=x.y.z-SUFFIX
. The POM version is set from this variable.
The build-ci reads project/properties/revision
to extract the POM version and alters the version as appropriate depending on the current branch.
Using this approach I can achieve the required results without adding any extra commits as Maven can execute its goals using the version provided externally.
Upvotes: 6