Skip to content

Instantly share code, notes, and snippets.

@kagarlickij
Last active March 3, 2023 16:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kagarlickij/7a506a27c66203fd077643f6e111a6d7 to your computer and use it in GitHub Desktop.
Save kagarlickij/7a506a27c66203fd077643f6e111a6d7 to your computer and use it in GitHub Desktop.
This one is to get current Jira sprint number
#!/bin/bash
# This one is to be executed once to figure out rapidBoardId
#curl -u kagarlickij:Password -X GET -H "Content-Type: application/json" 'https://kagarlickij.atlassian.net/rest/greenhopper/1.0/rapidviews/list'
curl -u USER:PASSWORD -X GET -H "Content-Type: application/json" \
'https://JIRA.DOMAIN.NAME/rest/greenhopper/1.0/sprintquery/17?includeFutureSprints=true&includeHistoricSprints=false' \
| /usr/local/bin/jq '.sprints[] | select(.name | contains("PROJECTNAME")) | select(.state == "ACTIVE") | .name' | sed 's/[^0-9]*//g' > currentSprint.txt
echo "Current Sprint number in Jira is $(cat currentSprint.txt)"
@Kebechet
Copy link

Kebechet commented Mar 3, 2023

If others would like to use the same thing by vanilla api

html=$(curl -u ${USER_NAME}:${PASSWORD} -X GET -H "Content-Type: application/json" https://${COMPANY}.atlassian.net/rest/agile/1.0/board/${BOARD_NUMBER}/sprint)
SPRINT_NAME=$(echo "${html}" | jq '.values | first(.[] | select(.state=="active")) | .name')
SPRINT_NUMBER=$(echo "${SPRINT_NAME}" | grep -o -E '[0-9]+')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment