Shell command to update pom file from a variable

后端 未结 6 1491
[愿得一人]
[愿得一人] 2021-01-06 17:24

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/bas         


        
6条回答
  •  既然无缘
    2021-01-06 18:09

    In here I mention fully working command. Thank you for your support.

    #!/bin/bash
    
    version=$(grep -ri "" pom.xml |head -n 1 | sed -e 's/^[ \t]*\ 
    ([^<]*\)<.*$/\1/')
    
    major=$(echo $version | cut -c1)
    var2=$(echo $version | cut -c2)
    miner=$(echo $version | cut -c3)
    var4=$(echo $version | cut -c4)
    bug=$(echo $version | cut -c5)
    bug=$((bug+1))
    str="-SNAPSHOT"
    incrementVer=$major$var2$miner$var4$bug$str
    echo $incrementVer
    
    LN=$(grep -n "" pom.xml | head -1 | awk -F ":" '{print $1}')
    sed -i "$LN s/$version/$incrementVer/" pom.xml
    

提交回复
热议问题