Skip to content

Instantly share code, notes, and snippets.

@rtyler
Created September 28, 2018 18:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rtyler/32e201037b6012779bb9727578255204 to your computer and use it in GitHub Desktop.
Save rtyler/32e201037b6012779bb9727578255204 to your computer and use it in GitHub Desktop.
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