Skip to content

Instantly share code, notes, and snippets.

View antweiss's full-sized avatar

Ant Weiss antweiss

View GitHub Profile
@amosshapira
amosshapira / jenkins-plugins-puppet.sh
Last active February 2, 2017 12:48
Extract list of current plugins from Jenkins and convert them into a Puppet hash with versions, suitable to feed to "plugin_hash" parameter of "rtyler-jenkins" Puppet class
# aligns the '=>' to be accepted by our puppet-lint. The indentation is very
# specific to our source so will have to be adjusted to other files.
# The "29" in the awk printf is the length of the longest plugin name, so all
# other entries are aligned with it. You can get it using "wc -c <<<(longest-plugin-name)"
java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar \
-s http://localhost list-plugins | \
tr -d '()' | \ # get rid of versions in parenthesis, perhaps available upgrades
sort | \
awk '{ printf " \047%s\047%*s=> {\n version => \047%s\047,\n },\n", $1, 29-length($1), "", $NF }'