The simplest and "manual form"
The simplest practice to get an artifact with the review of VCS in the file name is to put the desired revision in the version configured in the pom.xml
. Although it is a "manual" procedure, it helps to maintain a certain consistency.
The Versions Maven Plugin can help a little in this task.
Using the plugin for releases
There is still the Maven Release Plugin which could be useful depending on what your process is like. It is able to create a tag in SVN and update the poms version.
Changing the "final" name of the artifact in Maven
In Maven, you can set the tag <finalName>
in his pom.xml
so that, after the build, the final artifact has the name you want. See the documentation here.
By default, Maven adds the pom version as follows:
<finalName>${artifactId}-${version}</finalName>
So you could define any other property, for example:
<finalName>${artifactId}-${revisao_svn}</finalName>
And Jenkins could be configured to pass the parameter ${revisao_svn}
for the Maven.
If you use a hook (hook) like the of this page, then you’ll have the revision number on a property.
Finally, simply configure the parameters of the build as explained at this link. According to this answer that is perfectly possible.
Note: currently I do not have an environment to test all this, so unless someone gives a more detailed solution, you will have to unravel the details of the procedure.
Jenkins already comes with Maven integration in the "basic package". No need to change anything in pom.xml to configure Jenkins.
– Victor Stafusa
Personally, I think this is a bad idea, since it will break the Maven versioning system.
– Daniel C. Sobral