[Asterisk-code-review] CI: Add jenkinsfile for PQ internal testing (asterisk[16])
George Joseph
asteriskteam at digium.com
Fri Feb 7 09:33:18 CST 2020
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13732 )
Change subject: CI: Add jenkinsfile for PQ internal testing
......................................................................
CI: Add jenkinsfile for PQ internal testing
Change-Id: I818ff575f115e2b52162ae0bc39fb71dbf01be36
---
A tests/CI/pq.jenkinsfile
1 file changed, 165 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/13732/1
diff --git a/tests/CI/pq.jenkinsfile b/tests/CI/pq.jenkinsfile
new file mode 100644
index 0000000..9f45817
--- /dev/null
+++ b/tests/CI/pq.jenkinsfile
@@ -0,0 +1,165 @@
+/*
+ * This pipeline is the "template" for running the internal private testsuite
+ * tests against Asterisk.
+ *
+ * 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.
+ */
+def timeoutTime = 3
+def timeoutUnits = 'HOURS'
+if (env.TIMEOUT_DAILIES) {
+ def _timeout = env.TIMEOUT_DAILIES.split()
+ timeoutTime = _timeout[0].toInteger()
+ timeoutUnits = _timeout[1]
+}
+
+pipeline {
+ options {
+ timestamps()
+ timeout(time: timeoutTime, unit: timeoutUnits)
+ }
+
+ 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 {
+ 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 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
+ def dockerOptions = "--privileged --ulimit core=0 --ulimit nofile=10240 " +
+ " --tmpfs /tmp:exec,size=1G -v /srv/jenkins:/srv/jenkins:rw -v /srv/cache:/srv/cache:rw " +
+ " --entrypoint=''"
+ def bt = env.BUILD_TAG.replaceAll(/[^a-zA-Z0-9_.-]/, '-')
+ def outputdir = "tests/CI/output/asterisk"
+
+ manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Image: ${randomImage}", false)
+ def img = docker.image(randomImage)
+ img.pull()
+
+ img.inside(dockerOptions + " --name ${bt}-build") {
+ stage ("Build") {
+ echo 'Building..'
+ env.CCACHE_DIR = "/srv/cache/ccache"
+ sh "./tests/CI/buildAsterisk.sh --branch-name=${BRANCH_NAME} --output-dir=${outputdir} --cache-dir=/srv/cache"
+
+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
+ artifacts: "${outputdir}/*"
+ }
+ stage ("Install") {
+ echo 'Installing..'
+ sh "sudo ./tests/CI/installAsterisk.sh --branch-name=${BRANCH_NAME} --user-group=jenkins:users"
+ }
+ }
+
+ def testGroups
+ configFileProvider([configFile(fileId: 'asterisk_pq_tests', variable: 'PQ_TESTS')]) {
+ echo "Retrieved config file from ${env.PQ_TESTS}"
+ testGroups = readJSON file: env.PQ_TESTS
+ }
+
+ 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
+ def groupRunTestsuiteOptions = testGroup.runTestsuiteOptions
+ def testsuiteUrl = "http://gerrit.asterisk.org/testsuite"
+ def privateTestsuiteUrl = "http://gerrit.digium.internal/r/private-testsuite-tests"
+
+ parallelTasks[groupName] = {
+ stage (groupName) {
+
+ img.inside("${dockerOptions} --name ${bt}-${groupName}") {
+
+ lock("${JOB_NAME}.${NODE_NAME}.installer") {
+ sh "sudo ./tests/CI/installAsterisk.sh --uninstall-all --branch-name=${BRANCH_NAME} --user-group=jenkins:users"
+ }
+
+ sh "sudo rm -rf ${groupDir} || : "
+
+ checkout scm: [$class: 'GitSCM',
+ branches: [[name: "master"]],
+ extensions: [
+ [$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir],
+ [$class: 'CloneOption',
+ noTags: true,
+ depth: 10,
+ honorRefspec: true,
+ shallow: true
+ ],
+ ],
+ userRemoteConfigs: [[url: testsuiteUrl]]
+ ]
+ checkout scm: [$class: 'GitSCM',
+ branches: [[name: 'master']],
+ extensions: [
+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "${groupDir}/tests/custom"],
+ [$class: 'CloneOption',
+ noTags: true,
+ depth: 10,
+ honorRefspec: true,
+ shallow: true
+ ],
+ ],
+ userRemoteConfigs: [[url: privateTestsuiteUrl]]
+ ]
+
+ sh "sudo tests/CI/runTestsuite.sh ${groupRunTestsuiteOptions} --testsuite-dir='${groupDir}' --testsuite-command='${groupTestcmd}'"
+
+ 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 >/dev/null 2>&1 || : "
+ sh "sudo rm -rf tests/CI/output >/dev/null 2>&1 || : "
+ }
+ success {
+ echo "Reporting ${currentBuild.currentResult} Passed"
+ }
+ failure {
+ echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"
+ }
+ unstable {
+ echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"
+ }
+ }
+}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13732
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I818ff575f115e2b52162ae0bc39fb71dbf01be36
Gerrit-Change-Number: 13732
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200207/f81d164a/attachment.html>
More information about the asterisk-code-review
mailing list