[Asterisk-code-review] CI: Add "throttle" label and "skip_gate" capability (...testsuite[13])

Friendly Automation asteriskteam at digium.com
Thu Aug 8 10:28:47 CDT 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/testsuite/+/12708 )

Change subject: CI:  Add "throttle" label and "skip_gate" capability
......................................................................

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: Icd3158c66acf4d72c8bcd5948e8b3fca398aac4a
---
M CI/gates.jenkinsfile
M CI/unittests.jenkinsfile
2 files changed, 34 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/CI/gates.jenkinsfile b/CI/gates.jenkinsfile
index 26e30de..80dc390 100644
--- a/CI/gates.jenkinsfile
+++ b/CI/gates.jenkinsfile
@@ -10,7 +10,22 @@
  * we need to dynamically determine which docker image we're going to use and
  * you can't do that in a delcarative pipeline.
  */
+def timeoutTime = 60
+def timeoutUnits = 'MINUTES'
+if (env.TIMEOUT_GATES) {
+	def _timeout = env.TIMEOUT_GATES.split()
+	timeoutTime = _timeout[0].toInteger()
+	timeoutUnits = _timeout[1]
+}
+
 pipeline {
+    options {
+        ansiColor('gnome-terminal')
+        throttle(['testsuite-gate'])
+        timestamps()
+        timeout(time: timeoutTime, unit: timeoutUnits)
+    }
+
 	triggers {
 		/*
 		 * This trigger will match either the "asterisk" or "Security-asterisk"
@@ -56,7 +71,8 @@
 			 */
 			when {
 				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 {
 				script {
@@ -66,7 +82,7 @@
 					stage ("Checkout") {
 						sh "sudo chown -R jenkins:users ."
 						env.GERRIT_PROJECT_URL = env.GIT_URL.replaceAll(/[^\/]+$/, env.GERRIT_PROJECT)
-						sh "printenv | sort"
+						sh "printenv -0 | sort -z | tr '\0' '\n'"
 
 						/*
 						 * Jenkins has already automatically checked out the base branch
diff --git a/CI/unittests.jenkinsfile b/CI/unittests.jenkinsfile
index 943c1d0..81ce1ab 100644
--- a/CI/unittests.jenkinsfile
+++ b/CI/unittests.jenkinsfile
@@ -10,7 +10,22 @@
  * we need to dynamically determine which docker image we're going to use and
  * you can't do that in a delcarative pipeline.
  */
+def timeoutTime = 30
+def timeoutUnits = 'MINUTES'
+if (env.TIMEOUT_UNITTESTS) {
+	def _timeout = env.TIMEOUT_UNITTESTS.split()
+	timeoutTime = _timeout[0].toInteger()
+	timeoutUnits = _timeout[1]
+}
+
 pipeline {
+    options {
+        ansiColor('gnome-terminal')
+        throttle(['testsuite-check'])
+        timestamps()
+        timeout(time: timeoutTime, unit: timeoutUnits)
+    }
+
 	triggers {
 		/*
 		 * This trigger will match either the "asterisk" or "Security-asterisk"
@@ -69,7 +84,7 @@
 					stage ("Checkout") {
 						sh "sudo chown -R jenkins:users ."
 						env.GERRIT_PROJECT_URL = env.GIT_URL.replaceAll(/[^\/]+$/, env.GERRIT_PROJECT)
-						sh "printenv | sort"
+						sh "printenv -0 | sort -z | tr '\0' '\n'"
 
 						/*
 						 * Jenkins has already automatically checked out the base branch

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/12708
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-Change-Id: Icd3158c66acf4d72c8bcd5948e8b3fca398aac4a
Gerrit-Change-Number: 12708
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190808/034112e1/attachment.html>


More information about the asterisk-code-review mailing list