| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | /* | 
					
						
							|  |  |  |  * This pipeline is the "template" for the Asterisk Periodic 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 | 
					
						
							|  |  |  |  * you can't do that in a delcarative pipeline. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | pipeline { | 
					
						
							|  |  |  | 	triggers { | 
					
						
							|  |  |  | 		cron 'H H(0-4) * * *' | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 	agent { | 
					
						
							|  |  |  | 		/* All of the stages need to be performed on a docker host */ | 
					
						
							|  |  |  | 		label "swdev-docker" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	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-13 05:56:38 -06:00
										 |  |  | 					stage ("Checkout") { | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 						sh "sudo chown -R jenkins:users ." | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 						sh "printenv | sort" | 
					
						
							|  |  |  | 						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 " + | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 						" -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " + | 
					
						
							|  |  |  | 						" --entrypoint=''" | 
					
						
							| 
									
										
										
										
											2018-07-16 06:16:51 -06:00
										 |  |  | 					def bt = env.BUILD_TAG.replaceAll(/[^a-zA-Z0-9_.-]/, '-') | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 					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-13 05:56:38 -06:00
										 |  |  | 					def img = docker.image(randomImage) | 
					
						
							|  |  |  | 					img.pull() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 					img.inside(dockerOptions + " --name ${bt}-build") { | 
					
						
							|  |  |  | 						stage ("Build") { | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 							echo 'Building..' | 
					
						
							|  |  |  | 							env.CCACHE_DIR = "/srv/cache/ccache" | 
					
						
							| 
									
										
										
										
											2018-07-25 09:20:20 -06:00
										 |  |  | 							sh "./tests/CI/buildAsterisk.sh --branch-name=${BRANCH_NAME} --output-dir=${outputdir} --cache-dir=/srv/cache" | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false, | 
					
						
							|  |  |  | 								artifacts: "${outputdir}/*" | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 						stage ("Docs") { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 09:20:20 -06:00
										 |  |  | 							sh "sudo ./tests/CI/installAsterisk.sh --branch-name=${BRANCH_NAME}  --user-group=jenkins:users" | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							def docUrl = env.GIT_URL.replaceAll(/\/[^\/]+$/, "/publish-docs") | 
					
						
							|  |  |  | 							checkout scm: [$class: 'GitSCM', | 
					
						
							|  |  |  | 								branches: [[name: "master"]], | 
					
						
							|  |  |  | 									extensions: [ | 
					
						
							|  |  |  | 										[$class: 'RelativeTargetDirectory', relativeTargetDir: "tests/CI/output/publish-docs"], | 
					
						
							|  |  |  | 										[$class: 'CloneOption', | 
					
						
							|  |  |  | 											noTags: true, | 
					
						
							|  |  |  | 											depth: 10, | 
					
						
							|  |  |  | 											honorRefspec: true, | 
					
						
							|  |  |  | 											shallow: true | 
					
						
							|  |  |  | 										], | 
					
						
							|  |  |  | 									], | 
					
						
							|  |  |  | 									userRemoteConfigs: [[url: docUrl]] | 
					
						
							|  |  |  | 								] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-24 04:22:36 -06:00
										 |  |  | 							sh "./tests/CI/publishAsteriskDocs.sh --user-group=jenkins:users --branch-name=${BRANCH_NAME} --wiki-doc-branch-regex=\"${WIKI_DOC_BRANCH_REGEX}\"" | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					def testGroups = readJSON file: "tests/CI/periodic-dailyTestGroups.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-16 09:49:54 -06:00
										 |  |  | 						def groupRunTestsuiteOptions = testGroup.runTestsuiteOptions | 
					
						
							| 
									
										
										
										
											2018-07-17 09:41:40 -06:00
										 |  |  | 						def testsuiteUrl = env.GIT_URL.replaceAll(/\/[^\/]+$/, "/testsuite") | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						parallelTasks[groupName] = { | 
					
						
							|  |  |  | 							stage (groupName) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 06:16:51 -06:00
										 |  |  | 								img.inside("${dockerOptions} --name ${bt}-${groupName}") { | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 									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-13 05:56:38 -06:00
										 |  |  | 									} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 									sh "sudo rm -rf ${groupDir} || : " | 
					
						
							| 
									
										
										
										
											2018-07-19 09:34:51 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -06:00
										 |  |  | 									checkout scm: [$class: 'GitSCM', | 
					
						
							|  |  |  | 										branches: [[name: "${BRANCH_NAME}"]], | 
					
						
							|  |  |  | 											extensions: [ | 
					
						
							|  |  |  | 												[$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir], | 
					
						
							|  |  |  | 												[$class: 'CloneOption', | 
					
						
							|  |  |  | 													noTags: true, | 
					
						
							|  |  |  | 													depth: 10, | 
					
						
							|  |  |  | 													honorRefspec: true, | 
					
						
							|  |  |  | 													shallow: true | 
					
						
							|  |  |  | 												], | 
					
						
							|  |  |  | 											], | 
					
						
							|  |  |  | 											userRemoteConfigs: [[url: testsuiteUrl]] | 
					
						
							|  |  |  | 										] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-23 11:23:22 -04:00
										 |  |  | 									sh "sudo tests/CI/runTestsuite.sh ${groupRunTestsuiteOptions} --testsuite-dir='${groupDir}' --testsuite-command='${groupTestcmd}'" | 
					
						
							| 
									
										
										
										
											2018-07-13 05:56:38 -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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 									echo "Group result d: ${currentBuild.currentResult}" | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								echo "Group result s: ${currentBuild.currentResult}" | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					parallel parallelTasks | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	post { | 
					
						
							|  |  |  | 		cleanup { | 
					
						
							|  |  |  | 			sh "sudo make distclean 2&>/dev/null || : " | 
					
						
							|  |  |  | 			sh "sudo rm -rf tests/CI/output  2&>/dev/null || : " | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		success { | 
					
						
							|  |  |  | 			echo "Reporting ${currentBuild.currentResult} Passed" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		failure { | 
					
						
							|  |  |  | 			echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		unstable { | 
					
						
							|  |  |  | 			echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |