summaryrefslogtreecommitdiffstats
path: root/jjb
diff options
context:
space:
mode:
authorTrevor Bramwell <tbramwell@linuxfoundation.org>2017-05-19 14:23:54 -0700
committerTrevor Bramwell <tbramwell@linuxfoundation.org>2017-09-07 12:44:07 -0700
commit7f04bbb6864cff385c7ab975edfc9fa77cab674f (patch)
tree6ffaa1ec6a140b2fd499ed6d2900d45138ff517b /jjb
parenta6bc65d1efa18f56183c67035a77b616737212ec (diff)
Comment Pending JJB Changes on Patchset
Each time a patchset is created that has an effect on Jenkins jobs, a non-voting job will trigger that comments to Gerrit which jobs are added, modified, or deleted. This should help developers judge the overall impact an individual patchset may have on Jenkins since JJB macros can be expanded to any number of jobs. Change-Id: I99f9b68bc7933abfa39a941d6e65a73f62e58e56 Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'jjb')
-rwxr-xr-xjjb/releng/generate-job-list.sh68
-rw-r--r--jjb/releng/releng-ci-jobs.yml30
2 files changed, 98 insertions, 0 deletions
diff --git a/jjb/releng/generate-job-list.sh b/jjb/releng/generate-job-list.sh
new file mode 100755
index 000000000..0e35eaad4
--- /dev/null
+++ b/jjb/releng/generate-job-list.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 Linux Foundation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+# Job Number Formatter
+function JOBS {
+ local NUMS=$1
+ if [ $NUMS == 1 ]; then
+ echo -n "Job"
+ else
+ echo -n "Jobs"
+ fi
+}
+
+# We expect job_output to exist prior to this being run and contain the
+# output from jenkins-jobs test
+
+echo "> Generating list of previous JJB jobs..."
+git checkout -q -b previous-commit HEAD^
+jenkins-jobs -l ERROR test -r jjb -o job_output_prev
+git checkout -q - && git branch -q -d previous-commit
+
+echo "> Finding job changes ..."
+diff -r -q job_output job_output_prev &> job_diff.txt || true
+
+# Only in (job_output) = NEW
+# Only in (job_output_prev) = DELETED
+# Files ... differ = MODIFIED
+
+declare -a JOBS_ADDED=($(grep 'job_output:' job_diff.txt | cut -d':' -f2- | sed 's/^[ \t]*//;s/[ \t]*$//'))
+declare -a JOBS_MODIFIED=($(grep 'differ$' job_diff.txt | sed "s/Files job_output\/\(.*\) and.*/\1/g"))
+declare -a JOBS_REMOVED=($(grep 'job_output_prev:' job_diff.txt | cut -d ':' -f2- | sed 's/^[ \t]*//;s/[ \t]*$//'))
+
+NUM_JOBS_ADDED=${#JOBS_ADDED[@]}
+NUM_JOBS_MODIFIED=${#JOBS_MODIFIED[@]}
+NUM_JOBS_REMOVED=${#JOBS_REMOVED[@]}
+
+echo "> Writing gerrit comment ..."
+if [ $NUM_JOBS_ADDED -gt 0 ]; then
+ JOB_STRING="$(JOBS $NUM_JOBS_ADDED)"
+ { printf "Added %s %s:\n\n" "${NUM_JOBS_ADDED}" "$JOB_STRING";
+ printf '* %s\n' "${JOBS_ADDED[@]}";
+ printf "\n"; } >> gerrit_comment.txt
+fi
+
+if [ $NUM_JOBS_MODIFIED -gt 0 ]; then
+ JOB_STRING="$(JOBS $NUM_JOBS_MODIFIED)"
+ { printf "Modified %s %s:\n\n" "${NUM_JOBS_MODIFIED}" "$JOB_STRING";
+ printf '* %s\n' "${JOBS_MODIFIED[@]}";
+ printf "\n"; } >> gerrit_comment.txt
+fi
+
+if [ $NUM_JOBS_REMOVED -gt 0 ]; then
+ JOB_STRING="$(JOBS $NUM_JOBS_REMOVED)"
+ { printf "Removed %s %s:\n\n" "${NUM_JOBS_REMOVED}" "$JOB_STRING";
+ printf '* %s\n' "${JOBS_REMOVED[@]}";
+ printf "\n"; } >> gerrit_comment.txt
+fi
diff --git a/jjb/releng/releng-ci-jobs.yml b/jjb/releng/releng-ci-jobs.yml
index dc9bfd5dc..42d88fb7a 100644
--- a/jjb/releng/releng-ci-jobs.yml
+++ b/jjb/releng/releng-ci-jobs.yml
@@ -3,6 +3,7 @@
jobs:
- 'releng-verify-jjb'
- 'releng-merge-jjb'
+ - 'releng-comment-jjb'
- 'releng-generate-artifacts-api'
project: 'releng'
@@ -55,6 +56,35 @@
- email-jenkins-admins-on-failure
- job-template:
+ name: releng-comment-jjb
+
+ parameters:
+ - project-parameter:
+ project: '{project}'
+ branch: 'master'
+ scm:
+ - git-scm-gerrit
+
+ triggers:
+ - experimental:
+ project: '{project}'
+ branch: 'master'
+ files: 'jjb/**'
+
+ builders:
+ - copyartifact:
+ project: releng-merge-jjb
+ filter: "job_output/*"
+ which-build: last-successful
+ stable: true
+ optional: false
+ flatten: false
+ do-not-fingerprint: true
+ - shell:
+ !include-raw-escape: generate-job-list.sh
+ - report-build-result-to-gerrit
+
+- job-template:
name: 'releng-merge-jjb'
# builder-merge job to run JJB update