Previously I used below command to take the version in pom.xml and increment it from one. Before increment snapshot version is, 0.0.1
#!/bin/bash
version=$(grep -ri "<version>" pom.xml |head -n 1 | sed -e 's/^[ \t]*
<version>\([^<]*\)<.*$/\1/' | sed 's/[-SNAPSHOT]//g')
var1=$(echo $version | cut -c1)
var2=$(echo $version | cut -c2)
var3=$(echo $version | cut -c3)
var4=$(echo $version | cut -c4)
var5=$(echo $version | cut -c5)
var5=$((var5+1))
incrementVer=$var1$var2$var3$var4$var5
echo $incrementVer
output is 0.0.2
But I want to push this output into pom file and update as, <version>0.0.2</version>
Can I use sed command to update pom file?
My pom file looks like this,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mss.inven</groupId>
<artifactId>INVEN</artifactId>
<version>0.0.1-SNAPSHOT</version>