From 3c2375eadab4a508f85e0fcda7c7524b25b59067 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 21 Jul 2022 17:57:20 +0200 Subject: [PATCH] CI: do not trigger tests if nothing is tagged NSA The previous version would trigger sub-pipelines (LTE-2x2, ...) if no MR had the NSA tag (without a commit, etc). Of course, this would make all pipelines subsequently fail (as not enough arguments, such as the commit, were given). In this commit, we read the output of `jq` from JSON, which will result in an empty list if no MR is tagged with the NSA label (and the output in the console will be nicer as well). --- ci-scripts/Jenkinsfile-trig-nsa | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index 3616b2c404..8e81b75e58 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -20,6 +20,9 @@ * contact@openairinterface.org */ +// necessary for reading JSON +import groovy.json.JsonSlurper + // Template Jenkins Declarative Pipeline script to run Test w/ RF HW // Location of the python executor node shall be in the same subnet as the others servers @@ -37,12 +40,12 @@ pipeline { stages { stage ("Launcher") { steps { - script { - //retrieve MR that are opened nd with tag NSA - MR_LIST= sh returnStdout: true, script: 'curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100&labels=NSA" | jq ".[].iid" || true ' - echo "List of selected MR:\n${MR_LIST}" - def MR_ARRAY = MR_LIST.split('\n') - //for every selected MR, retrieve the branch name and the latest commit + script { + // retrieve MR that are opened nd with tag NSA + MR_LIST = sh returnStdout: true, script: 'curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100&labels=NSA" | jq -cj "[.[].iid]"' + echo "List of selected MRs: ${MR_LIST.trim()}" + def MR_ARRAY = new JsonSlurper().parseText(MR_LIST.trim()) + // for every selected MR, retrieve the branch name and the latest commit for (MR in MR_ARRAY) { SRC_BRANCH=sh returnStdout: true, script: """curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests/${MR}" | jq ".source_branch" || true """ SRC_BRANCH=SRC_BRANCH.trim()