Upgrade to global-jjb v0.17.0
[ci-management.git] / jjb / include-update-pom-versions-not-parent.sh
1 #!/bin/bash
2
3 ## Will update POM in workspace with release version
4
5 if [ ! -e version.properties ]; then
6     echo "Missing version.properties"
7     exit 1
8 fi
9
10 ## will setup variable release_version
11 source ./version.properties
12
13 RELEASE_VERSION=$release_version
14
15 echo Changing POM version to $RELEASE_VERSION
16
17 ## handle POM
18 for file in $(find . -name pom.xml); do
19     VERSION=$(xpath -q -e '//project/version/text()' $file)
20     PVERSION=$(xpath -q -e '//project/parent/version/text()' $file)
21     echo before changes VERSION=$VERSION PVERSION=$PVERSION file=$file
22     if [ "$VERSION" != "" ]; then
23         awk -v v=$RELEASE_VERSION '
24             /<version>/ {
25                 if (! done) {
26                     sub(/<version>.*</,"<version>" v "<",$0)
27                     done = 1
28                 }
29             }
30             { print $0 }
31         ' $file > $file.tmp
32         mv $file.tmp $file
33     fi
34     VERSION=$(xpath -q -e '//project/version/text()' $file)
35     PVERSION=$(xpath -q -e '//project/parent/version/text()' $file)
36     echo after changes VERSION=$VERSION PVERSION=$PVERSION file=$file
37 done
38