Skip to content

Commit aeb843f

Browse files
committed
Migrate all scripts to use standard variables for Jira
1 parent 74df639 commit aeb843f

File tree

24 files changed

+212
-131
lines changed

24 files changed

+212
-131
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: 7 additions & 5 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,17 @@
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+
# Load Jira Configuration.
34+
source ../jira.sh
35+
3336
# wipe the workspace
3437
rm -fr "${WORKSPACE}"/*
3538

@@ -39,7 +42,6 @@ echo -n > "${resultfile}"
3942

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

4446
# Normalise criteria
4547
criteria=${criteria// /_}

tracker_automations/bulk_prelaunch_jobs/bulk_prelaunch_jobs.sh

Lines changed: 6 additions & 4 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,17 @@
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+
# Load Jira Configuration.
32+
source ../jira.sh
33+
3134
# wipe the workspace
3235
rm -fr "${WORKSPACE}"/*
3336

@@ -37,7 +40,6 @@ echo -n > "${resultfile}"
3740

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

4244
# Normalise criteria
4345
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,23 @@ 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+
# Load Jira Configuration.
34+
source ../jira.sh
35+
3336
# file where results will be sent
3437
resultfile="$WORKSPACE/check_marked_as_integrated.csv"
3538
echo -n > "${resultfile}"
3639

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

4244
# Include some utility functions

tracker_automations/close_tested_issues/close_tested_issues.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
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+
# Load Jira Configuration.
28+
source ../jira.sh
29+
2730
# file where results will be sent
2831
resultfile=$WORKSPACE/close_tested_issues.csv
2932
echo -n > "${resultfile}"
@@ -33,7 +36,6 @@ logfile=$WORKSPACE/close_tested_issues.log
3336

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

3941
# Set closedate and closecomment if not specified
@@ -59,8 +61,8 @@ for issue in $( sed -n 's/^"\(MDL-[0-9]*\)".*/\1/p' "${resultfile}" ); do
5961
--issue ${issue} \
6062
--transition "Mark as committed" \
6163
--resolution "Fixed" \
62-
--field "customfield_10211=" \
63-
--field "customfield_10210=${altdate}" \
64+
--field "customfield_${customfield_currentlyInIntegration}=" \
65+
--field "customfield_${customfield_integrationDate}=${altdate}" \
6466
--comment "${altcomment}"
6567
echo "$BUILD_NUMBER $BUILD_TIMESTAMP ${issue}" >> "${logfile}"
6668
done

tracker_automations/component_leads_integration_mover/component_leads_integration_mover.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
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+
# Load Jira Configuration.
27+
source ../jira.sh
28+
2629
# We need curl to execute this script.
2730
if [[ ! $(which curl) ]]; then
2831
echo "Error: This script needs \"curl\" installed to work"
@@ -47,7 +50,6 @@ clrfile=${WORKSPACE}/clr.json
4750

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

5355
if [[ "${clearcache}" == "true" ]]; then
@@ -110,9 +112,8 @@ if [ "${nowdate}" -ge "${freezedate}" ] && [ "${nowdate}" -lt "${onsyncenddate}"
110112
fi
111113

112114
# 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.
114115
${basereq} --action getIssueList \
115-
--jql "filter = 23535 ${excludequery}" \
116+
--jql "filter = ${filter_integrationCLRDecision} ${excludequery}" \
116117
--columns="Key,Assignee,Peer reviewer,Components,Security Level,Summary" \
117118
--outputFormat=4 \
118119
--outputType=json \
@@ -159,13 +160,13 @@ jq -c '.[]' ${resultfile} | while read -r json; do
159160
# we are setting some custom fields not available (on purpose) on that screen. So we have created a
160161
# global transition, only available to the bots, not transitioning but bringing access to all the fields
161162
# 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).
163+
# "Component Lead Review" field: (Yes => CLR, No => IR, empty => undecided).
163164
if [[ "${outcome}" == "IR" ]]; then
164165
# No CLR. Just update the field.
165166
${basereq} --action transitionIssue \
166167
--issue ${issue} \
167168
--transition "CI Global Self-Transition" \
168-
--field "customfield_15810=No"
169+
--field "customfield_${customfield_componentLeadReview}=No"
169170
else
170171
# CLR. Real transition to Waiting for CLR.
171172
${basereq} --action transitionIssue \

tracker_automations/continuous_manage_queues/continuous_manage_queues.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@
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+
# Load Jira Configuration.
56+
source ../jira.sh
57+
5558
# file where results will be sent
5659
resultfile=$WORKSPACE/continuous_manage_queues.csv
5760
echo -n > "${resultfile}"
@@ -61,7 +64,6 @@ logfile=$WORKSPACE/continuous_manage_queues.log
6164

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

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

0 commit comments

Comments
 (0)