Created
November 28, 2017 08:18
-
-
Save sgoger/cdf5c1b4fae22fd77b9acdfd7ac890b3 to your computer and use it in GitHub Desktop.
Simple bash script retrieving jira releases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################ | |
################### USAGE ################## | |
############################################ | |
# Mostly inspired from http://blog.tremblay.pro/2014/10/extract-release-notes-from-jira.html | |
# | |
# base_url: | |
# jira base URL without trailing slash (http://jira.domain.org) | |
# project: | |
# project key (PROJ) | |
# version: | |
# version for which you want the release notes (1.0) | |
# user: | |
# user for HTTP_AUTH (simon) | |
# pass: | |
# pass for HTTP_AUTH (mySuperSafePassword) | |
# | |
# Usage: jira_release-notes.sh [base_url] [project] [version] [user] [password] | |
# jira_release-notes.sh http://jira.domain.org PROJ 1.0 simon mySuperSafePassword | |
base_url=$1 | |
project=$2 | |
version=$3 | |
user=$4 | |
user_pass=$5 | |
# Seems complicated but I'm just adding a backslash before the . in 3.2 | |
escaped_version=$(echo $version | sed "s/\([0-9]*\)\.\([0-9]*\)/\1\\\.\2/") | |
# Retrieve all versions and the id. Hoping a bit that the fields will stay in the same order | |
jira_version_id=$(curl -u "$user:$user_pass" --silent "$base_url/rest/api/2/project/$project/versions" | grep -o "\"id\":\"[0-9]*\",\"name\":\"$escaped_version\"" | cut -d'"' -f4) | |
# Retrieve project Id from key | |
jira_project_id=$(curl -u "$user:$user_pass" --silent "$base_url/rest/api/2/project/$project" | grep -o "\"id\":\"[0-9]*\",\"key\":\"$project\"" | cut -d'"' -f4) | |
# Get the page | |
release_notes_page="$base_url/secure/ReleaseNote.jspa?version=${jira_version_id}&styleName=Html&projectId=$jira_project_id" | |
release_notes=$(curl -u "$user:$user_pass" --silent "$release_notes_page") | |
# Extract the interesting info | |
echo "$release_notes" | sed -n "/<textarea rows=\"40\" cols=\"120\" id=\"editcopy\">/,/<\/textarea>/p" | grep -v "textarea" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment