<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13732">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CI: Add jenkinsfile for PQ internal testing<br><br>Change-Id: I818ff575f115e2b52162ae0bc39fb71dbf01be36<br>---<br>A tests/CI/pq.jenkinsfile<br>1 file changed, 165 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/13732/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/CI/pq.jenkinsfile b/tests/CI/pq.jenkinsfile</span><br><span>new file mode 100644</span><br><span>index 0000000..9f45817</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/pq.jenkinsfile</span><br><span>@@ -0,0 +1,165 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This pipeline is the "template" for running the internal private testsuite</span><br><span style="color: hsl(120, 100%, 40%);">+ * tests against Asterisk.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file starts as a declarative pipeline because with a declarative</span><br><span style="color: hsl(120, 100%, 40%);">+ * pipeline, you can define the trigger in the pipeline file. This keeps</span><br><span style="color: hsl(120, 100%, 40%);">+ * everything in one place. We transition to scripted pipeline later on because</span><br><span style="color: hsl(120, 100%, 40%);">+ * we need to dynamically determine which docker image we're going to use and</span><br><span style="color: hsl(120, 100%, 40%);">+ * you can't do that in a delcarative pipeline.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+def timeoutTime = 3</span><br><span style="color: hsl(120, 100%, 40%);">+def timeoutUnits = 'HOURS'</span><br><span style="color: hsl(120, 100%, 40%);">+if (env.TIMEOUT_DAILIES) {</span><br><span style="color: hsl(120, 100%, 40%);">+ def _timeout = env.TIMEOUT_DAILIES.split()</span><br><span style="color: hsl(120, 100%, 40%);">+ timeoutTime = _timeout[0].toInteger()</span><br><span style="color: hsl(120, 100%, 40%);">+ timeoutUnits = _timeout[1]</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+pipeline {</span><br><span style="color: hsl(120, 100%, 40%);">+ options {</span><br><span style="color: hsl(120, 100%, 40%);">+ timestamps()</span><br><span style="color: hsl(120, 100%, 40%);">+ timeout(time: timeoutTime, unit: timeoutUnits)</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ agent {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* All of the stages need to be performed on a docker host */</span><br><span style="color: hsl(120, 100%, 40%);">+ label "swdev-docker"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ stages {</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("->") {</span><br><span style="color: hsl(120, 100%, 40%);">+ steps {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Here's where we switch to scripted pipeline */</span><br><span style="color: hsl(120, 100%, 40%);">+ script {</span><br><span style="color: hsl(120, 100%, 40%);">+ manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Host: ${NODE_NAME}", false)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("Checkout") {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo chown -R jenkins:users ."</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "printenv | sort"</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo tests/CI/setupJenkinsEnvironment.sh"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def images = env.DOCKER_IMAGES.split(' ')</span><br><span style="color: hsl(120, 100%, 40%);">+ def r = currentBuild.startTimeInMillis % images.length</span><br><span style="color: hsl(120, 100%, 40%);">+ def ri = images[(int)r]</span><br><span style="color: hsl(120, 100%, 40%);">+ def randomImage = env.DOCKER_REGISTRY + "/" + ri</span><br><span style="color: hsl(120, 100%, 40%);">+ def dockerOptions = "--privileged --ulimit core=0 --ulimit nofile=10240 " +</span><br><span style="color: hsl(120, 100%, 40%);">+ " --tmpfs /tmp:exec,size=1G -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +</span><br><span style="color: hsl(120, 100%, 40%);">+ " --entrypoint=''"</span><br><span style="color: hsl(120, 100%, 40%);">+ def bt = env.BUILD_TAG.replaceAll(/[^a-zA-Z0-9_.-]/, '-')</span><br><span style="color: hsl(120, 100%, 40%);">+ def outputdir = "tests/CI/output/asterisk"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Image: ${randomImage}", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ def img = docker.image(randomImage)</span><br><span style="color: hsl(120, 100%, 40%);">+ img.pull()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ img.inside(dockerOptions + " --name ${bt}-build") {</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("Build") {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo 'Building..'</span><br><span style="color: hsl(120, 100%, 40%);">+ env.CCACHE_DIR = "/srv/cache/ccache"</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "./tests/CI/buildAsterisk.sh --branch-name=${BRANCH_NAME} --output-dir=${outputdir} --cache-dir=/srv/cache"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ artifacts: "${outputdir}/*"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ stage ("Install") {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo 'Installing..'</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo ./tests/CI/installAsterisk.sh --branch-name=${BRANCH_NAME} --user-group=jenkins:users"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def testGroups</span><br><span style="color: hsl(120, 100%, 40%);">+ configFileProvider([configFile(fileId: 'asterisk_pq_tests', variable: 'PQ_TESTS')]) {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Retrieved config file from ${env.PQ_TESTS}"</span><br><span style="color: hsl(120, 100%, 40%);">+ testGroups = readJSON file: env.PQ_TESTS</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def parallelTasks = [ : ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ for (def testGroup in testGroups) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Because each task is a Groovy closure, we need to</span><br><span style="color: hsl(120, 100%, 40%);">+ * keep local references to some variables.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupName = testGroup.name</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupDir = testGroup.dir</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupTestcmd = testGroup.testcmd</span><br><span style="color: hsl(120, 100%, 40%);">+ def groupRunTestsuiteOptions = testGroup.runTestsuiteOptions</span><br><span style="color: hsl(120, 100%, 40%);">+ def testsuiteUrl = "http://gerrit.asterisk.org/testsuite"</span><br><span style="color: hsl(120, 100%, 40%);">+ def privateTestsuiteUrl = "http://gerrit.digium.internal/r/private-testsuite-tests"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ parallelTasks[groupName] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ stage (groupName) {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ img.inside("${dockerOptions} --name ${bt}-${groupName}") {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ lock("${JOB_NAME}.${NODE_NAME}.installer") {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo ./tests/CI/installAsterisk.sh --uninstall-all --branch-name=${BRANCH_NAME} --user-group=jenkins:users"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo rm -rf ${groupDir} || : "</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ checkout scm: [$class: 'GitSCM',</span><br><span style="color: hsl(120, 100%, 40%);">+ branches: [[name: "master"]],</span><br><span style="color: hsl(120, 100%, 40%);">+ extensions: [</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir],</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'CloneOption',</span><br><span style="color: hsl(120, 100%, 40%);">+ noTags: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ depth: 10,</span><br><span style="color: hsl(120, 100%, 40%);">+ honorRefspec: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ shallow: true</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ userRemoteConfigs: [[url: testsuiteUrl]]</span><br><span style="color: hsl(120, 100%, 40%);">+ ]</span><br><span style="color: hsl(120, 100%, 40%);">+ checkout scm: [$class: 'GitSCM',</span><br><span style="color: hsl(120, 100%, 40%);">+ branches: [[name: 'master']],</span><br><span style="color: hsl(120, 100%, 40%);">+ extensions: [</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "${groupDir}/tests/custom"],</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'CloneOption',</span><br><span style="color: hsl(120, 100%, 40%);">+ noTags: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ depth: 10,</span><br><span style="color: hsl(120, 100%, 40%);">+ honorRefspec: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ shallow: true</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ userRemoteConfigs: [[url: privateTestsuiteUrl]]</span><br><span style="color: hsl(120, 100%, 40%);">+ ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo tests/CI/runTestsuite.sh ${groupRunTestsuiteOptions} --testsuite-dir='${groupDir}' --testsuite-command='${groupTestcmd}'"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ artifacts: "${groupDir}/asterisk-test-suite-report.xml, ${groupDir}/logs/**, ${groupDir}/core*.txt"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ junit testResults: "${groupDir}/asterisk-test-suite-report.xml",</span><br><span style="color: hsl(120, 100%, 40%);">+ healthScaleFactor: 1.0,</span><br><span style="color: hsl(120, 100%, 40%);">+ keepLongStdio: true</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Group result d: ${currentBuild.currentResult}"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Group result s: ${currentBuild.currentResult}"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ parallel parallelTasks</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ post {</span><br><span style="color: hsl(120, 100%, 40%);">+ cleanup {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo make distclean >/dev/null 2>&1 || : "</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "sudo rm -rf tests/CI/output >/dev/null 2>&1 || : "</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ success {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Reporting ${currentBuild.currentResult} Passed"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ failure {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ unstable {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13732">change 13732</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13732"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I818ff575f115e2b52162ae0bc39fb71dbf01be36 </div>
<div style="display:none"> Gerrit-Change-Number: 13732 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>