Skip to content

Instantly share code, notes, and snippets.

@iamkristian
Created June 3, 2011 11:10
Show Gist options
  • Save iamkristian/1006198 to your computer and use it in GitHub Desktop.
Save iamkristian/1006198 to your computer and use it in GitHub Desktop.
Get all projects from pivotal tracker and counted by state
#!/bin/bash
TOKEN=`curl -u $1:$2 -silent -k -X GET https://www.pivotaltracker.com/services/v3/tokens/active| sed -n -e 's/.*<guid>\(.*\)<\/guid>.*/\1/p'`
#curl -H "X-TrackerToken: $TOKEN" -X GET http://www.pivotaltracker.com/services/v3/projects
STORIES=/tmp/stories.xml
curl -H "X-TrackerToken: $TOKEN" -silent -X GET "http://www.pivotaltracker.com/services/v3/projects/$3/stories" > $STORIES
EMAIL_RECIPIENTS="$4"
EMAIL_SUBJECT="Story status fra Pivotal Tracker for project id: $3"
EMAIL_MSG=/tmp/stories_sum
echo $STORIES
echo "Stories loaded `date +%Y-%m-%d`" > $EMAIL_MSG
echo "Accepted: `egrep -c "<current_state>accepted</current_state>" $STORIES`" >> $EMAIL_MSG
echo "Delivered: `egrep -c "<current_state>delivered</current_state>" $STORIES`" >> $EMAIL_MSG
echo "Finished: `egrep -c "<current_state>finished</current_state>" $STORIES`" >> $EMAIL_MSG
echo "Started: `egrep -c "<current_state>started</current_state>" $STORIES`" >> $EMAIL_MSG
echo "Unstarted: `egrep -c "<current_state>unstarted</current_state>" $STORIES`" >> $EMAIL_MSG
echo "Unscheduled: `egrep -c "<current_state>unscheduled</current_state>" $STORIES`" >> $EMAIL_MSG
echo "-------" >> $EMAIL_MSG
echo `date +%Y-%m-%d` >> $EMAIL_MSG
echo `egrep -c "<current_state>accepted</current_state>" $STORIES` >> $EMAIL_MSG
echo `egrep -c "<current_state>delivered</current_state>" $STORIES` >> $EMAIL_MSG
echo `egrep -c "<current_state>finished</current_state>" $STORIES` >> $EMAIL_MSG
echo `egrep -c "<current_state>started</current_state>" $STORIES` >> $EMAIL_MSG
echo `egrep -c "<current_state>unstarted</current_state>" $STORIES` >> $EMAIL_MSG
echo `egrep -c "<current_state>unscheduled</current_state>" $STORIES` >> $EMAIL_MSG
/bin/mail -s "$EMAIL_SUBJECT" "$EMAIL_RECIPIENTS" < $EMAIL_MSG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment