Created
September 28, 2018 18:57
-
-
Save rtyler/32e201037b6012779bb9727578255204 to your computer and use it in GitHub Desktop.
A simple script to update a pom.xml for the latest updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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