Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions jira.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# This file contains the standard configuration relating to all queries used for tracker automations.
# Any use of numeric custom fields or filters should be defined here.
# This file should be sourced by any script that needs to use the tracker.

set -e

customfield_automatedTestResults=17112
customfield_componentLeadReview=15810
customfield_currentlyInIntegration=10211
customfield_integrationDate=10210
customfield_integrationPriority=12210
customfield_integrator=10110
customfield_pullFromRepository=10100
customfield_tester=10011

filter_candidatesForCLR=23329
filter_candidatesForIntegration=14000
filter_integrationCLRDecision=23535
filter_issuesHeldUntilAfterRelease=21366
filter_issuesVotedToUnhold=22054
filter_issuesWaitingForReviewOrInProgress=22610
filter_mustFixIssues=21363

# Verify everything is set
required="jiraclicmd jiraserver jirauser jirapass"
for var in $required; do
if [ -z "${!var}" ]; then
echo "Error: ${var} environment variable is not defined. See the script comments."
exit 1
fi
done

# Set the base request command.
basereq="${jiraclicmd} --server ${jiraserver} --user ${jirauser} --password ${jirapass}"
15 changes: 9 additions & 6 deletions tracker_automations/bulk_precheck_issues/bulk_precheck_issues.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#jiraserver: jira server url we are going to connect to
#jirauser: user that will perform the execution
#jirapass: password of the user
#cf_repository: id for "Pull from Repository" custom field (customfield_10100)
#cf_branches: pairs of moodle branch and id for "Pull XXXX Branch" custom field (main:customfield_10111,....)
#cf_testinginstructions: id for testing instructions custom field (customfield_10117)
#cf_repository: id for "Pull from Repository" custom field (customfield_XXXXX)
#cf_branches: pairs of moodle branch and id for "Pull XXXX Branch" custom field (main:customfield_XXXXX,....)
#cf_testinginstructions: id for testing instructions custom field (customfield_XXXXX)
#criteria: "awaiting peer review", "awaiting integration", "developer request"
#informtofiles: comma separated list of files where each MDL processed will be informed (format MDL-xxxx unixseconds)
#$maxcommitswarn: Max number of commits accepted per run. Warning if exceeded. Defaults to 10.
Expand All @@ -22,14 +22,19 @@
set -e

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

mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load Jira Configuration.
source "${mydir}/../../jira.sh"

# wipe the workspace
rm -fr "${WORKSPACE}"/*

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

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

# Normalise criteria
criteria=${criteria// /_}
Expand Down
13 changes: 8 additions & 5 deletions tracker_automations/bulk_prelaunch_jobs/bulk_prelaunch_jobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#jenkinsauth: String that defines the method to connect to the jenkins server, can be -ssh
# (requiring keys to be in place and jenkins ssh enabled), or also -html (and then
# use a combination of user and password or token). See Jenkins CLI docs for more info.
#cf_repository: id for "Pull from Repository" custom field (customfield_10100)
#cf_repository: id for "Pull from Repository" custom field (customfield_XXXXX)
#cf_branches: comma separated trios of moodle branch, id for "Pull XXXX Branch" custom field and php version.
# Trios are colon separated, example: main:customfield_10111:7.3,....). All them required.
# Trios are colon separated, example: main:customfield_XXXXX:7.3,....). All them required.
#criteria: "awaiting integration"...
#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.
#jobtype: defaulting to "all", allows to just pick one of the available jobs: phpunit, behat-(firefox|chrome|nonjs|all).
Expand All @@ -20,14 +20,19 @@
set -e

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

mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load Jira Configuration.
source "${mydir}/../../jira.sh"

# wipe the workspace
rm -fr "${WORKSPACE}"/*

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

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

# Normalise criteria
criteria=${criteria// /_}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
${basereq} --action getIssueList \
--jql "project = 'Moodle' \
AND issue IN (${issueslist}) \
AND cf[10100] ~ 'integration/security-testing' \
AND cf[${customfield_pullFromRepository}] ~ 'integration/security-testing' \
AND level IS NOT EMPTY \
ORDER BY priority DESC, votes DESC, 'Last comment date' ASC" \
--outputFormat 101 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ if [ -z "$gitremotename" ]; then
fi

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

mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load Jira Configuration.
source "${mydir}/../../jira.sh"

# file where results will be sent
resultfile="$WORKSPACE/check_marked_as_integrated.csv"
echo -n > "${resultfile}"

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

# Include some utility functions
Expand Down
13 changes: 8 additions & 5 deletions tracker_automations/close_tested_issues/close_tested_issues.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
set -e

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

mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load Jira Configuration.
source "${mydir}/../../jira.sh"

# file where results will be sent
resultfile=$WORKSPACE/close_tested_issues.csv
echo -n > "${resultfile}"
Expand All @@ -32,8 +37,6 @@ echo -n > "${resultfile}"
logfile=$WORKSPACE/close_tested_issues.log

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

# Set closedate and closecomment if not specified
Expand All @@ -59,8 +62,8 @@ for issue in $( sed -n 's/^"\(MDL-[0-9]*\)".*/\1/p' "${resultfile}" ); do
--issue ${issue} \
--transition "Mark as committed" \
--resolution "Fixed" \
--field "customfield_10211=" \
--field "customfield_10210=${altdate}" \
--field "customfield_${customfield_currentlyInIntegration}=" \
--field "customfield_${customfield_integrationDate}=${altdate}" \
--comment "${altcomment}"
echo "$BUILD_NUMBER $BUILD_TIMESTAMP ${issue}" >> "${logfile}"
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
set -e

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

mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load Jira Configuration.
source "${mydir}/../../jira.sh"

# We need curl to execute this script.
if [[ ! $(which curl) ]]; then
echo "Error: This script needs \"curl\" installed to work"
Expand All @@ -46,8 +51,6 @@ logfile=${WORKSPACE}/component_leads_integration_mover.log
clrfile=${WORKSPACE}/clr.json

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

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

# Search for all the issues awaiting for integration and not being decided between CLR/IR.
# Note: customfield_10118 is the peer reviewer custom field.
${basereq} --action getIssueList \
--jql "filter = 23535 ${excludequery}" \
--jql "filter = ${filter_integrationCLRDecision} ${excludequery}" \
--columns="Key,Assignee,Peer reviewer,Components,Security Level,Summary" \
--outputFormat=4 \
--outputType=json \
Expand Down Expand Up @@ -159,13 +161,13 @@ jq -c '.[]' ${resultfile} | while read -r json; do
# we are setting some custom fields not available (on purpose) on that screen. So we have created a
# global transition, only available to the bots, not transitioning but bringing access to all the fields
# via special screen. So we'll ne using that global transition via transitionIssue instead.
# customfield_15810 is the "Component Lead Review" field (Yes => CLR, No => IR, empty => undecided).
# "Component Lead Review" field: (Yes => CLR, No => IR, empty => undecided).
if [[ "${outcome}" == "IR" ]]; then
# No CLR. Just update the field.
${basereq} --action transitionIssue \
--issue ${issue} \
--transition "CI Global Self-Transition" \
--field "customfield_15810=No"
--field "customfield_${customfield_componentLeadReview}=No"
else
# CLR. Real transition to Waiting for CLR.
${basereq} --action transitionIssue \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@
set -e

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

mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load Jira Configuration.
source "${mydir}/../../jira.sh"

# file where results will be sent
resultfile=$WORKSPACE/continuous_manage_queues.csv
echo -n > "${resultfile}"
Expand All @@ -60,8 +65,6 @@ echo -n > "${resultfile}"
logfile=$WORKSPACE/continuous_manage_queues.log

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

source ${mydir}/lib.sh # Add all the functions.
Expand Down
Loading
Loading