How to upload artifacts to nexus with auto generating the version by using jenkins shell? I am using this script and I want to generate the version automatically when artifact u
You can use ${env.BUILD_NUMBER}
variable in your Jenkins pipeline to specify the artifact version.
To do this there are few options:
mvn deploy
, then you can use ${revision}
parameter in pom.xml
file.
To do this, you need to put this variable into <version>
tag. E.g., <version>1.0-${revision}</version>
and then provide it to the maven command in Jenkins pipeline: mvn deploy -Drevision=${env.BUILD_NUMBER}
.
See this answer for details.${env.BUILD_NUMBER}
variable. See this for details.