Skip to content

Commit 71c7186

Browse files
authored
Merge pull request #343 from andrewnicols/jiraCloud
Migrate all scripts to use standard variables for Jira
2 parents 74df639 + 3cff0f1 commit 71c7186

File tree

24 files changed

+255
-151
lines changed

24 files changed

+255
-151
lines changed

jira.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This file contains the standard configuration relating to all queries used for tracker automations.
4+
# Any use of numeric custom fields or filters should be defined here.
5+
# This file should be sourced by any script that needs to use the tracker.
6+
7+
set -e
8+
9+
customfield_automatedTestResults=17112
10+
customfield_componentLeadReview=15810
11+
customfield_currentlyInIntegration=10211
12+
customfield_integrationDate=10210
13+
customfield_integrationPriority=12210
14+
customfield_integrator=10110
15+
customfield_pullFromRepository=10100
16+
customfield_tester=10011
17+
18+
filter_candidatesForCLR=23329
19+
filter_candidatesForIntegration=14000
20+
filter_integrationCLRDecision=23535
21+
filter_issuesHeldUntilAfterRelease=21366
22+
filter_issuesVotedToUnhold=22054
23+
filter_issuesWaitingForReviewOrInProgress=22610
24+
filter_mustFixIssues=21363
25+
26+
# Verify everything is set
27+
required="jiraclicmd jiraserver jirauser jirapass"
28+
for var in $required; do
29+
if [ -z "${!var}" ]; then
30+
echo "Error: ${var} environment variable is not defined. See the script comments."
31+
exit 1
32+
fi
33+
done
34+
35+
# Set the base request command.
36+
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"

tracker_automations/bulk_precheck_issues/bulk_precheck_issues.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#jiraserver: jira server url we are going to connect to
55
#jirauser: user that will perform the execution
66
#jirapass: password of the user
7-
#cf_repository: id for "Pull from Repository" custom field (customfield_10100)
8-
#cf_branches: pairs of moodle branch and id for "Pull XXXX Branch" custom field (main:customfield_10111,....)
9-
#cf_testinginstructions: id for testing instructions custom field (customfield_10117)
7+
#cf_repository: id for "Pull from Repository" custom field (customfield_XXXXX)
8+
#cf_branches: pairs of moodle branch and id for "Pull XXXX Branch" custom field (main:customfield_XXXXX,....)
9+
#cf_testinginstructions: id for testing instructions custom field (customfield_XXXXX)
1010
#criteria: "awaiting peer review", "awaiting integration", "developer request"
1111
#informtofiles: comma separated list of files where each MDL processed will be informed (format MDL-xxxx unixseconds)
1212
#$maxcommitswarn: Max number of commits accepted per run. Warning if exceeded. Defaults to 10.
@@ -22,14 +22,19 @@
2222
set -e
2323

2424
# Verify everything is set
25-
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass cf_repository cf_branches cf_testinginstructions criteria quiet jenkinsjobname jenkinsserver publishserver"
25+
required="WORKSPACE cf_repository cf_branches cf_testinginstructions criteria quiet jenkinsjobname jenkinsserver publishserver"
2626
for var in $required; do
2727
if [ -z "${!var}" ]; then
2828
echo "Error: ${var} environment variable is not defined. See the script comments."
2929
exit 1
3030
fi
3131
done
3232

33+
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
34+
35+
# Load Jira Configuration.
36+
source "${mydir}/../../jira.sh"
37+
3338
# wipe the workspace
3439
rm -fr "${WORKSPACE}"/*
3540

@@ -38,8 +43,6 @@ resultfile=${WORKSPACE}/bulk_precheck_issues
3843
echo -n > "${resultfile}"
3944

4045
# Calculate some variables
41-
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
42-
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
4346

4447
# Normalise criteria
4548
criteria=${criteria// /_}

tracker_automations/bulk_prelaunch_jobs/bulk_prelaunch_jobs.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#jenkinsauth: String that defines the method to connect to the jenkins server, can be -ssh
99
# (requiring keys to be in place and jenkins ssh enabled), or also -html (and then
1010
# use a combination of user and password or token). See Jenkins CLI docs for more info.
11-
#cf_repository: id for "Pull from Repository" custom field (customfield_10100)
11+
#cf_repository: id for "Pull from Repository" custom field (customfield_XXXXX)
1212
#cf_branches: comma separated trios of moodle branch, id for "Pull XXXX Branch" custom field and php version.
13-
# Trios are colon separated, example: main:customfield_10111:7.3,....). All them required.
13+
# Trios are colon separated, example: main:customfield_XXXXX:7.3,....). All them required.
1414
#criteria: "awaiting integration"...
1515
#schedulemins: Frecuency (in minutes) of the schedule (cron) of this job. IMPORTANT to ensure that they match or there will be issues processed more than once or skipped.
1616
#jobtype: defaulting to "all", allows to just pick one of the available jobs: phpunit, behat-(firefox|chrome|nonjs|all).
@@ -20,14 +20,19 @@
2020
set -e
2121

2222
# Verify everything is set
23-
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass jenkinsserver jenkinsauth cf_repository cf_branches criteria schedulemins quiet"
23+
required="WORKSPACE jenkinsserver jenkinsauth cf_repository cf_branches criteria schedulemins quiet"
2424
for var in $required; do
2525
if [ -z "${!var}" ]; then
2626
echo "Error: ${var} environment variable is not defined. See the script comments."
2727
exit 1
2828
fi
2929
done
3030

31+
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
32+
33+
# Load Jira Configuration.
34+
source "${mydir}/../../jira.sh"
35+
3136
# wipe the workspace
3237
rm -fr "${WORKSPACE}"/*
3338

@@ -36,8 +41,6 @@ resultfile=${WORKSPACE}/bulk_prelaunch_jobs
3641
echo -n > "${resultfile}"
3742

3843
# Calculate some variables
39-
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
40-
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
4144

4245
# Normalise criteria
4346
criteria=${criteria// /_}

tracker_automations/bulk_prelaunch_jobs/criteria/list_of_mdls_sdev/query.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
${basereq} --action getIssueList \
22
--jql "project = 'Moodle' \
33
AND issue IN (${issueslist}) \
4-
AND cf[10100] ~ 'integration/security-testing' \
4+
AND cf[${customfield_pullFromRepository}] ~ 'integration/security-testing' \
55
AND level IS NOT EMPTY \
66
ORDER BY priority DESC, votes DESC, 'Last comment date' ASC" \
77
--outputFormat 101 \

tracker_automations/check_marked_as_integrated/check_marked_as_integrated.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,24 @@ if [ -z "$gitremotename" ]; then
2222
fi
2323

2424
# Verify everything is set
25-
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass gitcmd gitdir gitremotename devbranches"
25+
required="WORKSPACE gitcmd gitdir gitremotename devbranches"
2626
for var in $required; do
2727
if [ -z "${!var}" ]; then
2828
echo "Error: ${var} environment variable is not defined. See the script comments."
2929
exit 1
3030
fi
3131
done
3232

33+
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
34+
35+
# Load Jira Configuration.
36+
source "${mydir}/../../jira.sh"
37+
3338
# file where results will be sent
3439
resultfile="$WORKSPACE/check_marked_as_integrated.csv"
3540
echo -n > "${resultfile}"
3641

3742
# Calculate some variables
38-
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
39-
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
4043
IFS=',' read -a devbranchesarr <<< "$devbranches" # Convert devbranches to array.
4144

4245
# Include some utility functions

tracker_automations/close_tested_issues/close_tested_issues.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616
set -e
1717

1818
# Verify everything is set
19-
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass"
19+
required="WORKSPACE"
2020
for var in $required; do
2121
if [ -z "${!var}" ]; then
2222
echo "Error: ${var} environment variable is not defined. See the script comments."
2323
exit 1
2424
fi
2525
done
2626

27+
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28+
29+
# Load Jira Configuration.
30+
source "${mydir}/../../jira.sh"
31+
2732
# file where results will be sent
2833
resultfile=$WORKSPACE/close_tested_issues.csv
2934
echo -n > "${resultfile}"
@@ -32,8 +37,6 @@ echo -n > "${resultfile}"
3237
logfile=$WORKSPACE/close_tested_issues.log
3338

3439
# Calculate some variables
35-
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
36-
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
3740
BUILD_TIMESTAMP="$(date +'%Y-%m-%d_%H-%M-%S')"
3841

3942
# Set closedate and closecomment if not specified
@@ -59,8 +62,8 @@ for issue in $( sed -n 's/^"\(MDL-[0-9]*\)".*/\1/p' "${resultfile}" ); do
5962
--issue ${issue} \
6063
--transition "Mark as committed" \
6164
--resolution "Fixed" \
62-
--field "customfield_10211=" \
63-
--field "customfield_10210=${altdate}" \
65+
--field "customfield_${customfield_currentlyInIntegration}=" \
66+
--field "customfield_${customfield_integrationDate}=${altdate}" \
6467
--comment "${altcomment}"
6568
echo "$BUILD_NUMBER $BUILD_TIMESTAMP ${issue}" >> "${logfile}"
6669
done

tracker_automations/component_leads_integration_mover/component_leads_integration_mover.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
set -e
1616

1717
# Verify everything is set
18-
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass jsonclrurl releasedate"
18+
required="WORKSPACE jsonclrurl releasedate"
1919
for var in $required; do
2020
if [ -z "${!var}" ]; then
2121
echo "Error: ${var} environment variable is not defined. See the script comments."
2222
exit 1
2323
fi
2424
done
2525

26+
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
27+
28+
# Load Jira Configuration.
29+
source "${mydir}/../../jira.sh"
30+
2631
# We need curl to execute this script.
2732
if [[ ! $(which curl) ]]; then
2833
echo "Error: This script needs \"curl\" installed to work"
@@ -46,8 +51,6 @@ logfile=${WORKSPACE}/component_leads_integration_mover.log
4651
clrfile=${WORKSPACE}/clr.json
4752

4853
# Calculate some variables
49-
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
50-
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
5154
BUILD_TIMESTAMP="$(date +'%Y-%m-%d_%H-%M-%S')"
5255

5356
if [[ "${clearcache}" == "true" ]]; then
@@ -110,9 +113,8 @@ if [ "${nowdate}" -ge "${freezedate}" ] && [ "${nowdate}" -lt "${onsyncenddate}"
110113
fi
111114

112115
# Search for all the issues awaiting for integration and not being decided between CLR/IR.
113-
# Note: customfield_10118 is the peer reviewer custom field.
114116
${basereq} --action getIssueList \
115-
--jql "filter = 23535 ${excludequery}" \
117+
--jql "filter = ${filter_integrationCLRDecision} ${excludequery}" \
116118
--columns="Key,Assignee,Peer reviewer,Components,Security Level,Summary" \
117119
--outputFormat=4 \
118120
--outputType=json \
@@ -159,13 +161,13 @@ jq -c '.[]' ${resultfile} | while read -r json; do
159161
# we are setting some custom fields not available (on purpose) on that screen. So we have created a
160162
# global transition, only available to the bots, not transitioning but bringing access to all the fields
161163
# via special screen. So we'll ne using that global transition via transitionIssue instead.
162-
# customfield_15810 is the "Component Lead Review" field (Yes => CLR, No => IR, empty => undecided).
164+
# "Component Lead Review" field: (Yes => CLR, No => IR, empty => undecided).
163165
if [[ "${outcome}" == "IR" ]]; then
164166
# No CLR. Just update the field.
165167
${basereq} --action transitionIssue \
166168
--issue ${issue} \
167169
--transition "CI Global Self-Transition" \
168-
--field "customfield_15810=No"
170+
--field "customfield_${customfield_componentLeadReview}=No"
169171
else
170172
# CLR. Real transition to Waiting for CLR.
171173
${basereq} --action transitionIssue \

tracker_automations/continuous_manage_queues/continuous_manage_queues.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@
4444
set -e
4545

4646
# Verify everything is set
47-
required="WORKSPACE jiraclicmd jiraserver jirauser jirapass releasedate"
47+
required="WORKSPACE releasedate"
4848
for var in $required; do
4949
if [ -z "${!var}" ]; then
5050
echo "Error: ${var} environment variable is not defined. See the script comments."
5151
exit 1
5252
fi
5353
done
5454

55+
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
56+
57+
# Load Jira Configuration.
58+
source "${mydir}/../../jira.sh"
59+
5560
# file where results will be sent
5661
resultfile=$WORKSPACE/continuous_manage_queues.csv
5762
echo -n > "${resultfile}"
@@ -60,8 +65,6 @@ echo -n > "${resultfile}"
6065
logfile=$WORKSPACE/continuous_manage_queues.log
6166

6267
# Calculate some variables
63-
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
64-
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
6568
BUILD_TIMESTAMP="$(date +'%Y-%m-%d_%H-%M-%S')"
6669

6770
source ${mydir}/lib.sh # Add all the functions.

0 commit comments

Comments
 (0)