Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple script to update a pom.xml for the latest updates
#!/usr/bin/env bash
DEPENDS=$(xmlstarlet sel -N x='http://maven.apache.org/POM/4.0.0' \
-t -m x:project/x:dependencies/x:dependency \
-v x:artifactId -o ' ' \
pom.xml)
if [ ! -f update-center.actual.json ]; then
wget https://updates.jenkins.io/update-center.actual.json;
fi;
for d in $DEPENDS; do
VERSION=$(jq -r ".plugins[\"${d}\"].version" < update-center.actual.json)
echo "> ${d} should be ${VERSION}"
# Thanksk to this post for enough pointers
# https://stackoverflow.com/questions/51785967/xmlstarlet-select-and-update-xml
xmlstarlet ed \
--ps --inplace \
-N x='http://maven.apache.org/POM/4.0.0' \
-u "//x:artifactId[.='${d}']/following-sibling::x:version[1]" \
-v ${VERSION} \
pom.xml
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment