-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathprepare
executable file
·44 lines (33 loc) · 1.7 KB
/
prepare
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env sh
# Usage: bin/prepare [VERSION]
#
# Prepares the current directory according to the given Atlassian JIRA
# VERSION. If no VERSION information is specified the latest version is
# retrieved from the Atlassian JIRA download feed.
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] && [ -z "$1" ]; then
echo "Not master branch and therefore nothing to prepare"
exit 0
elif [ -n "${1}" ]; then
echo "Overriding latest Atlassian JIRA to ${1}"
fi
echo "Obtaining Altassian JIRA version information..."
# Obtain the currently latest version of Atlassian JIRA version defined by the
# Dockerfile in this repository.
CURRENT_VERSION=$(sed -nr 's/ENV JIRA_VERSION[[:space:]]*(.+)/\1/p' Dockerfile)
# Obtain the latest Atlassian JIRA version by going to the JSON version feed
# information to get a JSONP formatted response, strip the output to retrieve
# the actual content and then get the version number from the first entry.
curl -Ls 'https://my.atlassian.com/download/feeds/current/jira-software.json' | sed 's/downloads(\(.*\))/\1/g' | jq -r '.[] | select(.description | test("TAR\\.GZ Archive")) | ("" + .zipUrl + " " + .version)' | while read -r URL VERSION
do
echo "Found versions:"
echo " Current: ${CURRENT_VERSION}"
echo " Latest: ${VERSION}"
echo ""
echo "Preparing branch for version new Atlassian JIRA version"
# Edit the `Dockerfile` by changing the current version to the new obtained
# version from the Atlassian JIRA version feed.
sed --in-place "s/${CURRENT_VERSION}/${VERSION}/g" Dockerfile
NAME="${URL#https://www.atlassian.com/software/jira/downloads/binary/}"
sed --in-place "s/atlassian-jira-software-.*.tar.gz/${NAME}/g" Dockerfile
echo "Ready for acceptance testing"
done