Skip to content

Instantly share code, notes, and snippets.

@kyleterry
Created September 25, 2013 18:31
Show Gist options
  • Save kyleterry/6703942 to your computer and use it in GitHub Desktop.
Save kyleterry/6703942 to your computer and use it in GitHub Desktop.
#!/bin/bash
# In order for this parser to work, the file needs to be structured with
# tickets like the following:
#
# 12345678 - Some ticket title
# Action: UAT Needed.
# State: (APPROVED|PENDING|FAILED)
# Pivotal: https://www.pivotaltracker.com/s/projects/745189/stories/12345678
# Github: https://github.com/copious/Zumiez.com/pull/123
# Branch: feature/12345678-some-ticket-title
if [ ! ${#} -eq 2 ]; then
echo "Usage: ${0} deploy_20130101.txt (APPROVED|PENDING|FAILED)"
exit 1
fi
DEPLOY_FILE=${1}
STATUS=${2}
i=0
lines=$(wc -l ${DEPLOY_FILE} | awk '{print $1}')
total_groups=$(($lines / 6))
echo "Searching through ${total_groups} tickets"
for i in $(seq 1 6 ${lines})
do
ticket_data=$(tail -n +${i} ${DEPLOY_FILE} | head -n 6)
ticket_state=$(echo "${ticket_data}" | grep -i state: | awk '{print $2}')
if [ "${ticket_state}" == "${STATUS}" ]; then
echo "${ticket_data}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment