| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | /* | 
					
						
							|  |  |  |  * This pipeline is the "template" for the Asterisk REF_DEBUG Tests multi-branch | 
					
						
							|  |  |  |  * parent job.  Jenkins will automatically scan the branches in the "asterisk" | 
					
						
							|  |  |  |  * or "Security-asterisk" projects in Gerrit and automatically create a branch- | 
					
						
							|  |  |  |  * specific job for each branch it finds this file in. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file starts as a declarative pipeline because with a declarative | 
					
						
							|  |  |  |  * pipeline, you can define the trigger in the pipeline file.  This keeps | 
					
						
							|  |  |  |  * everything in one place.  We transition to scripted pipeline later on because | 
					
						
							|  |  |  |  * we need to dynamically determine which docker image we're going to use and | 
					
						
							| 
									
										
										
										
											2021-10-30 21:04:37 -04:00
										 |  |  |  * you can't do that in a declarative pipeline. | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-11-19 10:59:07 -07:00
										 |  |  | def timeoutTime = 24 | 
					
						
							|  |  |  | def timeoutUnits = 'HOURS' | 
					
						
							|  |  |  | if (env.TIMEOUT_REF_DEBUG) { | 
					
						
							|  |  |  | 	def _timeout = env.TIMEOUT_REF_DEBUG.split() | 
					
						
							|  |  |  | 	timeoutTime = _timeout[0].toInteger() | 
					
						
							|  |  |  | 	timeoutUnits = _timeout[1] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | pipeline { | 
					
						
							| 
									
										
										
										
											2018-10-04 09:13:22 -06:00
										 |  |  | 	options { | 
					
						
							| 
									
										
										
										
											2019-08-08 06:12:18 -06:00
										 |  |  | 		ansiColor('gnome-terminal') | 
					
						
							|  |  |  | 		throttle(['asterisk-ref-debug']) | 
					
						
							| 
									
										
										
										
											2018-10-04 09:13:22 -06:00
										 |  |  | 		timestamps() | 
					
						
							| 
									
										
										
										
											2018-11-19 10:59:07 -07:00
										 |  |  | 		timeout(time: timeoutTime, unit: timeoutUnits) | 
					
						
							| 
									
										
										
										
											2018-10-04 09:13:22 -06:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 	triggers { | 
					
						
							|  |  |  | 		cron 'H H(0-4) * * 0' | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-07-19 10:20:38 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 	agent { | 
					
						
							|  |  |  | 		/* All of the stages need to be performed on a docker host */ | 
					
						
							| 
									
										
										
										
											2019-08-06 09:40:54 -06:00
										 |  |  | 		label "asterisk-ref-debug" | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	stages { | 
					
						
							|  |  |  | 		stage ("->") { | 
					
						
							|  |  |  | 			steps { | 
					
						
							|  |  |  | 				/* Here's where we switch to scripted pipeline */ | 
					
						
							|  |  |  | 				script { | 
					
						
							| 
									
										
										
										
											2018-07-26 17:54:36 -06:00
										 |  |  | 					manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Host: ${NODE_NAME}", false) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 					stage ("Checkout") { | 
					
						
							| 
									
										
										
										
											2019-07-19 10:20:38 -06:00
										 |  |  | 						sh "sudo chown -R jenkins:users ." | 
					
						
							| 
									
										
										
										
											2019-08-08 11:10:11 -06:00
										 |  |  | 						sh "printenv -0 | sort -z | tr '\\0' '\\n'" | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 						sh "sudo tests/CI/setupJenkinsEnvironment.sh" | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					def images = env.DOCKER_IMAGES.split(' ') | 
					
						
							|  |  |  | 					def r = currentBuild.startTimeInMillis % images.length | 
					
						
							|  |  |  | 					def ri = images[(int)r] | 
					
						
							|  |  |  | 					def randomImage = env.DOCKER_REGISTRY + "/" + ri | 
					
						
							| 
									
										
										
										
											2018-07-24 04:39:30 -06:00
										 |  |  | 					def dockerOptions = "--privileged --ulimit core=0 --ulimit nofile=10240 " + | 
					
						
							| 
									
										
										
										
											2019-02-19 16:06:32 +00:00
										 |  |  | 						" --tmpfs /tmp:exec,size=1G -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " + | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 						" --entrypoint=''" | 
					
						
							|  |  |  | 					def bt = env.BUILD_TAG.replaceAll(/[^a-zA-Z0-9_.-]/, '-') | 
					
						
							|  |  |  | 					def outputdir = "tests/CI/output/Testsuite" | 
					
						
							| 
									
										
										
										
											2018-07-26 10:34:20 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Image: ${randomImage}", false) | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 					def img = docker.image(randomImage) | 
					
						
							|  |  |  | 					img.pull() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					stage ("Build") { | 
					
						
							|  |  |  | 						img.inside(dockerOptions + " --name ${bt}-build") { | 
					
						
							|  |  |  | 							echo 'Building..' | 
					
						
							|  |  |  | 							env.CCACHE_DIR = "/srv/cache/ccache" | 
					
						
							| 
									
										
										
										
											2018-07-25 09:20:20 -06:00
										 |  |  | 							sh "./tests/CI/buildAsterisk.sh --ref-debug --branch-name=${BRANCH_NAME} --output-dir=${outputdir} --cache-dir=/srv/cache" | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false, | 
					
						
							|  |  |  | 								artifacts: "${outputdir}/*" | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					def testGroups = readJSON file: "tests/CI/ref_debugTestGroups.json" | 
					
						
							|  |  |  | 					def parallelTasks = [ : ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					for (def testGroup in testGroups) { | 
					
						
							|  |  |  | 						/* | 
					
						
							|  |  |  | 						 * Because each task is a Groovy closure, we need to | 
					
						
							|  |  |  | 						 * keep local references to some variables. | 
					
						
							|  |  |  | 						 */ | 
					
						
							|  |  |  | 						def groupName = testGroup.name | 
					
						
							|  |  |  | 						def groupDir = testGroup.dir | 
					
						
							|  |  |  | 						def groupTestcmd = testGroup.testcmd | 
					
						
							| 
									
										
										
										
											2018-07-25 06:13:43 -06:00
										 |  |  | 						def testsuiteUrl = env.GIT_URL.replaceAll(/\/[^\/]+$/, "/testsuite") | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						parallelTasks[groupName] = { | 
					
						
							|  |  |  | 							stage (groupName) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								img.inside("${dockerOptions} --name ${bt}-${groupName}") { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 									lock("${JOB_NAME}.${NODE_NAME}.installer") { | 
					
						
							| 
									
										
										
										
											2018-07-27 12:23:02 -06:00
										 |  |  | 										sh "sudo ./tests/CI/installAsterisk.sh  --uninstall-all --branch-name=${BRANCH_NAME} --user-group=jenkins:users" | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 									} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 									sh "sudo rm -rf ${groupDir} || : " | 
					
						
							| 
									
										
										
										
											2019-07-19 10:20:38 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 									checkout scm: [$class: 'GitSCM', | 
					
						
							|  |  |  | 										branches: [[name: "${BRANCH_NAME}"]], | 
					
						
							|  |  |  | 											extensions: [ | 
					
						
							|  |  |  | 												[$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir], | 
					
						
							|  |  |  | 												[$class: 'CloneOption', | 
					
						
							|  |  |  | 													noTags: true, | 
					
						
							|  |  |  | 													honorRefspec: true, | 
					
						
							| 
									
										
										
										
											2019-12-02 05:48:01 -07:00
										 |  |  | 													shallow: false | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 												], | 
					
						
							|  |  |  | 											], | 
					
						
							|  |  |  | 											userRemoteConfigs: [[url: testsuiteUrl]] | 
					
						
							|  |  |  | 										] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-23 11:23:22 -04:00
										 |  |  | 									sh "sudo tests/CI/runTestsuite.sh --testsuite-dir='${groupDir}' --testsuite-command='${groupTestcmd}'" | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 									archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true, | 
					
						
							|  |  |  | 										artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 									junit testResults: "${groupDir}/asterisk-test-suite-report.xml", | 
					
						
							|  |  |  | 										healthScaleFactor: 1.0, | 
					
						
							|  |  |  | 										keepLongStdio: true | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					parallel parallelTasks | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	post { | 
					
						
							|  |  |  | 		cleanup { | 
					
						
							| 
									
										
										
										
											2019-11-19 11:11:06 -07:00
										 |  |  | 			script { | 
					
						
							|  |  |  | 				if (env.CLEANUP_WS_REF_DEBUG.toBoolean()) { | 
					
						
							|  |  |  | 					cleanWs deleteDirs: true, notFailBuild: false | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-11-19 07:51:56 -07:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-07-16 08:13:40 -06:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		success { | 
					
						
							|  |  |  | 			echo "Reporting ${currentBuild.currentResult} Passed" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		failure { | 
					
						
							|  |  |  | 			echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		unstable { | 
					
						
							|  |  |  | 			echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |