GoCD Maven Snippets

Some xmlstarlet stuff to get version etc …

GROUP_ID=$(xmlstarlet sel -T -t -v '/_:project/_:groupId' pom.xml)
ARTIFACT_ID=$(xmlstarlet sel -T -t -v '/_:project/_:artifactId' pom.xml)
VERSION=$(xmlstarlet sel -T -t -v '/_:project/_:version' pom.xml)
VERSION_START=$(echo $VERSION | cut -d '.' -f 1-2)

if [ -n "$GO_PIPELINE_COUNTER" ] ; then
    FULL_VERSION=${VERSION_START}.${GO_PIPELINE_COUNTER}.${GO_STAGE_COUNTER}
else
    FULL_VERSION=${VERSION_START}.0.1
fi

cat upstream*/dependency-properties.txt | sort -u > dependency-properties.txt
echo "<${ARTIFACT_ID}.version>${FULL_VERSION}</${ARTIFACT_ID}.version>" | sort -u  >> dependency-properties.txt

An example dependency-properties.txt could look like this:

<component.one>1.34.1</component.one>
<component.two>3.45.1</component.two>
This work by Fredrik Wendt is licensed under CC by-sa.