Guest User

Untitled

a guest
Nov 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Requirements
  4. PROGS=("xmlstarlet")
  5.  
  6. for PROG in "${PROGS[@]}" ; do
  7. command -v $PROG >/dev/null 2>&1 || { echo >&2 "System requirement $PROG not met. Please install $PROG"; exit 1; }
  8. done
  9.  
  10. # Sanity
  11. if [[ "$1" == "" ]] ; then
  12. JENKINS_PLUGIN_DIR="/var/lib/jenkins/plugins"
  13. else
  14. JENKINS_PLUGIN_DIR="$1"
  15. fi
  16.  
  17. if [ ! -d $JENKINS_PLUGIN_DIR ] ; then
  18. echo "Jenkins plugin directory is not a directory: ${JENKINS_PLUGIN_DIR}"
  19. exit 1
  20. fi
  21.  
  22. SPACES=$(printf "%0.s " {1..2})
  23.  
  24. # Process
  25. echo "initial:"
  26.  
  27. for LIC in `ls -1 $JENKINS_PLUGIN_DIR/*/WEB-INF/licenses.xml` ; do
  28. ART_ID=$(cat "${LIC}" | xmlstarlet sel -t -v '/l:dependencies/@artifactId')
  29. VER_ID=$(cat "${LIC}" | xmlstarlet sel -t -v '/l:dependencies/@version')
  30.  
  31. printf '%s- name: "%s"\n' "${SPACES}" "${ART_ID}"
  32. printf '%s version: "%s"\n' "${SPACES}" "${VER_ID}"
  33. done
Add Comment
Please, Sign In to add comment