enable filtering CSIT jobs 54/51054/8
authorMatt Welch <matt.welch@intel.com>
Thu, 26 Jan 2017 01:45:54 +0000 (17:45 -0800)
committerMatt Welch <matt.welch@intel.com>
Thu, 26 Jan 2017 20:59:39 +0000 (12:59 -0800)
This patch will enable filtering the list of CSIT jobs that DO
NOT match a supplied set of strings and DO match a supplied stream.
Streams correspond to development cycles like beryllium, boron,
carbon, etc.

Change-Id: Ia32164f97b9b506f7635e7a4bd6bd9e4ef005e7f
Signed-off-by: Matt Welch <matt.welch@intel.com>
jjb/integration/include-raw-integration-list-jobs.sh [new file with mode: 0644]
jjb/integration/integration-macros.yaml

diff --git a/jjb/integration/include-raw-integration-list-jobs.sh b/jjb/integration/include-raw-integration-list-jobs.sh
new file mode 100644 (file)
index 0000000..d8db9a0
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+# Script to filter Jenkins jobs against a blacklist
+# output: newline & comma-separated list
+
+system=releng
+search_string="{search_string}"
+if [ -n "$search_string" ] ; then
+    search_string=csit
+fi
+
+blacklist_in="{blacklist}"
+if [ -n "$blacklist_in" ] ; then
+    blacklist_in="longevity gate"
+fi
+blacklist=( $(echo ${{blacklist_in}}) )
+
+stream="{stream}"
+if [ -n "$stream" ] ; then
+    stream=carbon
+fi
+
+wget --quiet -O jenkins-jobs.xml https://jenkins.opendaylight.org/$system/api/xml
+jobs=$(xmlstarlet sel -t -m '//hudson/job' \
+    -n -v 'name' jenkins-jobs.xml | grep $search_string | grep $stream)
+
+bl_len=${{#blacklist[@]}}
+for (( i = 0; i < ${{bl_len}}; i++ )); do
+    jobs="$(echo "$jobs" | grep -v ${{blacklist[$i]}} )"
+done
+# output as comma-separated list with 8 spaces before each item
+echo $jobs | sed 's: :,\n:g' | sed 's:^\(.*\):        \1:g' > {jobs-filename}
+
index 4ac193bc60049a5a6575ce99b3b36921509915cf..83c2eb375d9e20d66d9d65fcf937888f6bd5dc3b 100644 (file)
         - shell:
             !include-raw:
                 - include-raw-integration-deploy-openstack-run-test.sh
+
+# Macro: integration-list-jobs
+# Operation: queries Jenkins jobs from jenkins.opendaylight.org and
+#   writes a list of the jobs corresponding to the search terms to a file.
+# Used by: builder-merge job template
+#
+# This script requires the following JJB variables to be passed in:
+#   {search_string}     Job type to act as a primary filter (e.g. csit)
+#   {blacklist}         List of sub-projects to filter out (e.g. longevity)
+#   {stream}            Development release name (e.g. boron)
+#   {jobs-filename}     Filename to write list into (e.g. carbon-jobs.lst)
+
+- builder:
+    name: integration-list-jobs
+    builders:
+        - shell:
+            !include-raw:
+                - include-raw-integration-list-jobs.sh
+
 ##############
 # Publishers #
 ##############