From: George Joseph Date: Thu, 8 Aug 2019 12:12:18 +0000 (-0600) Subject: CI: Add "throttle" label and "skip_gate" capability X-Git-Tag: certified/13.21-cert5~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c177b3566b4fd896d5719e63d5d60e1a47bd5294;p=thirdparty%2Fasterisk.git CI: Add "throttle" label and "skip_gate" capability To make throttling by label fully active, the "throttle" option has to be specified with a specific label. You can now specify "skip_gate" in the Gerrit comments when you do a +2 code review to tell Jenkins not to actually run the gate. You'd do this if you plan to manually merge the change. Also updated the "printenv" debug output to better sort multi-line comments. Change-Id: I4c0b1085acec4805f2ca207eebac50aad81f27e2 --- diff --git a/tests/CI/gates.jenkinsfile b/tests/CI/gates.jenkinsfile index 275610433c..e135656452 100644 --- a/tests/CI/gates.jenkinsfile +++ b/tests/CI/gates.jenkinsfile @@ -20,6 +20,8 @@ if (env.TIMEOUT_GATES) { pipeline { options { + ansiColor('gnome-terminal') + throttle(['asterisk-gate']) timestamps() timeout(time: timeoutTime, unit: timeoutUnits) } @@ -62,14 +64,15 @@ pipeline { stages { stage ("->") { - /* - * Jenkins will try to automatically rebuild this job when - * the jenkinsfile changes but since this job is dependent on - * Gerrit, we really don't want to do anything in that case. - */ when { + /* + * Jenkins will try to automatically rebuild this job when + * the jenkinsfile changes but since this job is dependent on + * Gerrit, we really don't want to do anything in that case. + */ not { environment name: 'GERRIT_CHANGE_NUMBER', value: '' } - not { environment name: 'GERRIT_EVENT_ACCOUNT_NAME', value: 'Jenkins2' } + /* If "skip_gate" is in the comments, don't run the job */ + not { expression { env.GERRIT_EVENT_COMMENT_TEXT ==~ /.*skip_gate.*/ } } } steps { /* Here's where we switch to scripted pipeline */ @@ -97,7 +100,7 @@ pipeline { withCredentials([usernamePassword(credentialsId: "${JENKINS_GERRIT_CREDS}", passwordVariable: 'GERRIT_USER_PW', usernameVariable: 'GERRIT_USER_NAME')]) { - sh "printenv | sort" + sh "printenv -0 | sort -z | tr '\0' '\n'" checkout scm: [$class: 'GitSCM', branches: [[name: env.GERRIT_BRANCH ]], diff --git a/tests/CI/periodics-daily.jenkinsfile b/tests/CI/periodics-daily.jenkinsfile index d9896d115f..1dba606e70 100644 --- a/tests/CI/periodics-daily.jenkinsfile +++ b/tests/CI/periodics-daily.jenkinsfile @@ -20,6 +20,8 @@ if (env.TIMEOUT_DAILIES) { pipeline { options { + ansiColor('gnome-terminal') + throttle(['asterisk-daily']) timestamps() timeout(time: timeoutTime, unit: timeoutUnits) } @@ -41,7 +43,7 @@ pipeline { stage ("Checkout") { sh "sudo chown -R jenkins:users ." - sh "printenv | sort" + sh "printenv -0 | sort -z | tr '\0' '\n'" sh "sudo tests/CI/setupJenkinsEnvironment.sh" } diff --git a/tests/CI/ref_debug.jenkinsfile b/tests/CI/ref_debug.jenkinsfile index 3c73d0e89d..82ace49246 100644 --- a/tests/CI/ref_debug.jenkinsfile +++ b/tests/CI/ref_debug.jenkinsfile @@ -20,13 +20,15 @@ if (env.TIMEOUT_REF_DEBUG) { pipeline { options { + ansiColor('gnome-terminal') + throttle(['asterisk-ref-debug']) timestamps() timeout(time: timeoutTime, unit: timeoutUnits) } triggers { cron 'H H(0-4) * * 0' } - + agent { /* All of the stages need to be performed on a docker host */ label "asterisk-ref-debug" @@ -40,8 +42,8 @@ pipeline { manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Host: ${NODE_NAME}", false) stage ("Checkout") { - sh "sudo chown -R jenkins:users ." - sh "printenv | sort" + sh "sudo chown -R jenkins:users ." + sh "printenv -0 | sort -z | tr '\0' '\n'" sh "sudo tests/CI/setupJenkinsEnvironment.sh" } @@ -93,7 +95,7 @@ pipeline { } sh "sudo rm -rf ${groupDir} || : " - + checkout scm: [$class: 'GitSCM', branches: [[name: "${BRANCH_NAME}"]], extensions: [ diff --git a/tests/CI/unittests.jenkinsfile b/tests/CI/unittests.jenkinsfile index e57a532537..793d634374 100644 --- a/tests/CI/unittests.jenkinsfile +++ b/tests/CI/unittests.jenkinsfile @@ -20,6 +20,8 @@ if (env.TIMEOUT_UNITTESTS) { pipeline { options { + ansiColor('gnome-terminal') + throttle(['asterisk-check']) timestamps() timeout(time: timeoutTime, unit: timeoutUnits) } @@ -98,7 +100,7 @@ pipeline { withCredentials([usernamePassword(credentialsId: "${JENKINS_GERRIT_CREDS}", passwordVariable: 'GERRIT_USER_PW', usernameVariable: 'GERRIT_USER_NAME')]) { - sh "printenv | sort" + sh "printenv -0 | sort -z | tr '\0' '\n'" checkout scm: [$class: 'GitSCM', branches: [[name: env.GERRIT_BRANCH ]],