I want to increment SNAPSHOT version in pom.xml file without using maven release plugin. Current version is,
0.0.1-SNAPSHOT
expected version is,
0.1.1-Snapshot
How can I do this by accessing pom.xml file? I am working on jenkins maven project. can I use sed command for this?
I used this command to change the pom version and it is working
grep -ri "<version>" pom.xml |head -n 1 | sed -i 's/>0.0.1-SNAPSHOT</>0.1.1-
SNAPSHOT</g' pom.xml
I guess you could give xmlstarlet
a try:
$ xmlstarlet ed -N mvn=http://maven.apache.org/POM/4.0.0 -u /mvn:project/mvn:version -v 0.1.1-Snapshot pom.xml
XMLStarlet is obviously XML-aware and as such it will be smarter if you move stuff around and will only update what you tell it to, since it uses XPath. For instance, having other <version>
tags in dependencies and parent will be handled correctly as well.
Please be aware that "snapshot" should be in caps.
Link to its documentation: http://xmlstar.sourceforge.net/docs.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.