<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13927">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CI: Create generic jenkinsfile<br><br>This is a generic jenkinsfile to build Asterisk and optionally<br>perform one or more of the following:<br> * Publish the API docs to the wiki<br> * Run the Unit tests<br> * Run Testsuite Tests<br><br>This job can be triggered manually from Jenkins or be triggered<br>automatically on a schedule based on a cron string.<br><br>Change-Id: Id9d22a778a1916b666e0e700af2b9f1bacda0852<br>---<br>A tests/CI/universal-asterisk-nongerrit.jenkinsfile<br>1 file changed, 452 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/CI/universal-asterisk-nongerrit.jenkinsfile b/tests/CI/universal-asterisk-nongerrit.jenkinsfile</span><br><span>new file mode 100644</span><br><span>index 0000000..d9b0cef</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/universal-asterisk-nongerrit.jenkinsfile</span><br><span>@@ -0,0 +1,452 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This is a generic jenkinsfile to build Asterisk and optionally</span><br><span style="color: hsl(120, 100%, 40%);">+ * perform one or more of the following:</span><br><span style="color: hsl(120, 100%, 40%);">+ * * Publish the API docs to the wiki</span><br><span style="color: hsl(120, 100%, 40%);">+ * * Run the Unit tests</span><br><span style="color: hsl(120, 100%, 40%);">+ * * Run Testsuite Tests</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This job can be triggered manually from Jenkins or be triggered</span><br><span style="color: hsl(120, 100%, 40%);">+ * automatically on a schedule based on a cron string.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * To use this jenkinsfile, create a new "Multi-Branch Pipeline" job</span><br><span style="color: hsl(120, 100%, 40%);">+ * in Jenkins. For easier configuration, the job name should contain</span><br><span style="color: hsl(120, 100%, 40%);">+ * only letters, numbers, or the "-", "_" and "." special characters.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Use the "by Jenkinsfile" "Build Configuration" mode and specify</span><br><span style="color: hsl(120, 100%, 40%);">+ * the path to this jenkinsfile.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * When you save this job definition, Jenkins will scan the git</span><br><span style="color: hsl(120, 100%, 40%);">+ * repository and find any branches with this Jenkinsfile and then try</span><br><span style="color: hsl(120, 100%, 40%);">+ * run the job. It's expected that the jobs will fail because you</span><br><span style="color: hsl(120, 100%, 40%);">+ * haven't create the config file yet.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * The job is configured from a Jenkins managed config file named</span><br><span style="color: hsl(120, 100%, 40%);">+ * "jobConfig". These files are created using the "Config Files"</span><br><span style="color: hsl(120, 100%, 40%);">+ * option of the base job and are unique to a job so you can create</span><br><span style="color: hsl(120, 100%, 40%);">+ * multiple jobs based on this Jenkinsfile without conflicts.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Create the file as a "Json file" remembering to change the ID</span><br><span style="color: hsl(120, 100%, 40%);">+ * from the auto-generated UUID to "jobConfig".</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Example contents:</span><br><span style="color: hsl(120, 100%, 40%);">+ * {</span><br><span style="color: hsl(120, 100%, 40%);">+ * cronString: 'H H(0-4) * * *',</span><br><span style="color: hsl(120, 100%, 40%);">+ * jobTimeout: {</span><br><span style="color: hsl(120, 100%, 40%);">+ * timeout: 2,</span><br><span style="color: hsl(120, 100%, 40%);">+ * units: 'HOURS',</span><br><span style="color: hsl(120, 100%, 40%);">+ * },</span><br><span style="color: hsl(120, 100%, 40%);">+ * jobCleanup: {</span><br><span style="color: hsl(120, 100%, 40%);">+ * keepBuilds: 5,</span><br><span style="color: hsl(120, 100%, 40%);">+ * artifactKeepBuilds: 2</span><br><span style="color: hsl(120, 100%, 40%);">+ * },</span><br><span style="color: hsl(120, 100%, 40%);">+ * throttleCategories: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * 'default'</span><br><span style="color: hsl(120, 100%, 40%);">+ * ],</span><br><span style="color: hsl(120, 100%, 40%);">+ * docker: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * images: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * 'asterisk/jenkins-agent-centos7'</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%);">+ * buildAsterisk: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * build: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ * env: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * REF_DEBUG: 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%);">+ * unitTests: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * run: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ * testCommand: 'test execute all'</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%);">+ * NOTE: The JSON file can actually reference variables from the</span><br><span style="color: hsl(120, 100%, 40%);">+ * environment using string interpolation. For example, if you</span><br><span style="color: hsl(120, 100%, 40%);">+ * need to substitute the current branch in a value for some reason,</span><br><span style="color: hsl(120, 100%, 40%);">+ * you could use:</span><br><span style="color: hsl(120, 100%, 40%);">+ * mybranch: "${BRANCH}"</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%);">+ * All jobConfig parameters have defaults BUT if left that way,</span><br><span style="color: hsl(120, 100%, 40%);">+ * only an Asterisk build will be done.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * NOTE: Groovy syntax uses brackets "[]" for both arrays and</span><br><span style="color: hsl(120, 100%, 40%);">+ * maps/dictionaries where JSON uses brackets "[]" for arrays but</span><br><span style="color: hsl(120, 100%, 40%);">+ * braces "{}" for maps/dictionaries. Your jobConfig file is JSON</span><br><span style="color: hsl(120, 100%, 40%);">+ * but the defaults below are Groovy.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+def jobConfig = [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Must match a label assigned to agents. */</span><br><span style="color: hsl(120, 100%, 40%);">+ agentLabel: 'swdev-docker',</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * https://jenkins.io/doc/book/pipeline/syntax/#cron-syntax</span><br><span style="color: hsl(120, 100%, 40%);">+ * If empty, job will not be scheduled and must be triggered manually.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ cronString: '',</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * An array of strings that name categories defined in Jenkins</span><br><span style="color: hsl(120, 100%, 40%);">+ * Global Settings under "Throttle Concurrent Builds". If you</span><br><span style="color: hsl(120, 100%, 40%);">+ * specify one or more categories, they MUST have been defined</span><br><span style="color: hsl(120, 100%, 40%);">+ * or the job will fail.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ throttleCategories: [</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ jobTimeout: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* How long should the job be allowed to run? */</span><br><span style="color: hsl(120, 100%, 40%);">+ timeout: 120,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Common valid units are "MINUTES", "HOURS", "DAYS". */</span><br><span style="color: hsl(120, 100%, 40%);">+ units: 'MINUTES'</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ jobCleanup: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The total number of past jobs to keep. */</span><br><span style="color: hsl(120, 100%, 40%);">+ keepBuilds: 14,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* But only this number will have their artifacts saved. */</span><br><span style="color: hsl(120, 100%, 40%);">+ artifactKeepBuilds: 7,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Clean up the workspace on the agent when the job completes. */</span><br><span style="color: hsl(120, 100%, 40%);">+ cleanupWorkspace: true</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ docker: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The host and port of our Docker image registry. */</span><br><span style="color: hsl(120, 100%, 40%);">+ registry: 'swdev-docker0:5000',</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * An array of images that can be used for this job.</span><br><span style="color: hsl(120, 100%, 40%);">+ * One will be chosen from the list at random.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ images: [</span><br><span style="color: hsl(120, 100%, 40%);">+ 'asterisk/jenkins-agent-centos7'</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%);">+ buildAsterisk: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Build Asterisk */</span><br><span style="color: hsl(120, 100%, 40%);">+ build: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Additional envuronment variables to pass to buildAsterisk.sh */</span><br><span style="color: hsl(120, 100%, 40%);">+ env: [</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%);">+ unitTests: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Run the Asterisk Unit Tests. */</span><br><span style="color: hsl(120, 100%, 40%);">+ run: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The Asterisk CLI command to run the tests. */</span><br><span style="color: hsl(120, 100%, 40%);">+ testCommand: 'test execute all'</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ wikiDocs: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Build and publish the wiki documentation? */</span><br><span style="color: hsl(120, 100%, 40%);">+ publish: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The URL to the "publish-docs" repository */</span><br><span style="color: hsl(120, 100%, 40%);">+ gitURL: "https://gerrit.asterisk.org/publish-docs",</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Only for branches that match the regex.</span><br><span style="color: hsl(120, 100%, 40%);">+ * I.E. Only the base branches excluding master.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ branchRegex: '^([0-9]+)$'</span><br><span style="color: hsl(120, 100%, 40%);">+ ],</span><br><span style="color: hsl(120, 100%, 40%);">+ testsuite: [</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Run the Testsuite? */</span><br><span style="color: hsl(120, 100%, 40%);">+ run: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The URL to the "testsuite" repository */</span><br><span style="color: hsl(120, 100%, 40%);">+ gitURL: "https://gerrit.asterisk.org/testsuite",</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * The name of the testsuite config file.</span><br><span style="color: hsl(120, 100%, 40%);">+ * See the "Testsuite" stage below for more info.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ configFile: 'testsuiteConfig',</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%);">+ * The easiest way to process the above defaults is to merge the</span><br><span style="color: hsl(120, 100%, 40%);">+ * values from the jobConfig file over the defaults map. Groovy</span><br><span style="color: hsl(120, 100%, 40%);">+ * provides a standard way to do this but it's not a deep operation</span><br><span style="color: hsl(120, 100%, 40%);">+ * so we provide our own deep merge function.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+Map merge(Map onto, Map... overrides) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!overrides)</span><br><span style="color: hsl(120, 100%, 40%);">+ return onto</span><br><span style="color: hsl(120, 100%, 40%);">+ else if (overrides.length == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ overrides[0]?.each { k, v -></span><br><span style="color: hsl(120, 100%, 40%);">+ if (v instanceof Map && onto[k] instanceof Map)</span><br><span style="color: hsl(120, 100%, 40%);">+ merge((Map) onto[k], (Map) v)</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ onto[k] = v</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return onto</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return overrides.inject(onto, { acc, override -> merge(acc, override ?: [:]) })</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%);">+ * The job setup steps such as reading the config file and merging the</span><br><span style="color: hsl(120, 100%, 40%);">+ * defaults can be done on the "master" node before we send the job off</span><br><span style="color: hsl(120, 100%, 40%);">+ * to an agent.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+node('master') {</span><br><span style="color: hsl(120, 100%, 40%);">+ def tempJobConfig</span><br><span style="color: hsl(120, 100%, 40%);">+ configFileProvider([configFile(fileId: 'jobConfig',</span><br><span style="color: hsl(120, 100%, 40%);">+ replaceTokens: true, variable: 'JOB_CONFIG_FILE')]) {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Retrieved jobConfig file from ${env.JOB_CONFIG_FILE}"</span><br><span style="color: hsl(120, 100%, 40%);">+ tempJobConfig = readJSON file: env.JOB_CONFIG_FILE</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ script {</span><br><span style="color: hsl(120, 100%, 40%);">+ merge(jobConfig, tempJobConfig)</span><br><span style="color: hsl(120, 100%, 40%);">+ echo jobConfig.toString()</span><br><span style="color: hsl(120, 100%, 40%);">+ causeClasses = currentBuild.getBuildCauses()</span><br><span style="color: hsl(120, 100%, 40%);">+ causeClass = causeClasses[0]</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Build Cause: ${causeClass.toString()}"</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%);">+pipeline {</span><br><span style="color: hsl(120, 100%, 40%);">+ triggers {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If jobConfig.cronString is empty (the default), the trigger will be ignored */</span><br><span style="color: hsl(120, 100%, 40%);">+ cron jobConfig.cronString</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%);">+ options {</span><br><span style="color: hsl(120, 100%, 40%);">+ throttle(jobConfig.throttleCategories)</span><br><span style="color: hsl(120, 100%, 40%);">+ timeout(time: jobConfig.jobTimeout.timeout, unit: jobConfig.jobTimeout.units)</span><br><span style="color: hsl(120, 100%, 40%);">+ buildDiscarder(</span><br><span style="color: hsl(120, 100%, 40%);">+ logRotator(numToKeepStr: "${jobConfig.jobCleanup.keepBuilds}",</span><br><span style="color: hsl(120, 100%, 40%);">+ artifactNumToKeepStr: "${jobConfig.jobCleanup.artifactKeepBuilds}"))</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%);">+ label jobConfig.agentLabel</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 ("Setup") {</span><br><span style="color: hsl(120, 100%, 40%);">+ when {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * When you make changes to the base job or a new branch is discovered</span><br><span style="color: hsl(120, 100%, 40%);">+ * Jenkins tries to run it the job. We probably don't want this to happen</span><br><span style="color: hsl(120, 100%, 40%);">+ * so if "BranchIndexing" was teh cause, don't run any of the steps.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ not {</span><br><span style="color: hsl(120, 100%, 40%);">+ triggeredBy 'BranchIndexingCause'</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%);">+ steps { script {</span><br><span style="color: hsl(120, 100%, 40%);">+ createSummary(icon: "/plugin/workflow-job/images/48x48/pipelinejob.png", text: "Docker Host: ${NODE_NAME}")</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 -0 | sort -z | tr '\\0' '\\n'"</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%);">+ /* Find a docker image, setup parameters and pull image */</span><br><span style="color: hsl(120, 100%, 40%);">+ def r = currentBuild.startTimeInMillis % jobConfig.docker.images.size()</span><br><span style="color: hsl(120, 100%, 40%);">+ def ri = jobConfig.docker.images[(int)r]</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Docker Image: ${ri}"</span><br><span style="color: hsl(120, 100%, 40%);">+ def randomImage = jobConfig.docker.registry + "/" + ri</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Docker Path: ${randomImage}"</span><br><span style="color: hsl(120, 100%, 40%);">+ 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%);">+ buildTag = env.BUILD_TAG.replaceAll(/[^a-zA-Z0-9_.-]/, '-')</span><br><span style="color: hsl(120, 100%, 40%);">+ dockerImage = docker.image(randomImage)</span><br><span style="color: hsl(120, 100%, 40%);">+ dockerImage.pull()</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%);">+ stage ("Build") {</span><br><span style="color: hsl(120, 100%, 40%);">+ when {</span><br><span style="color: hsl(120, 100%, 40%);">+ expression { jobConfig.buildAsterisk.build }</span><br><span style="color: hsl(120, 100%, 40%);">+ not {</span><br><span style="color: hsl(120, 100%, 40%);">+ triggeredBy 'BranchIndexingCause'</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%);">+ steps { script {</span><br><span style="color: hsl(120, 100%, 40%);">+ dockerImage.inside(dockerOptions + " --name ${buildTag}-build") {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo 'Building..'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ withEnv(jobConfig.buildAsterisk.env) {</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "./tests/CI/buildAsterisk.sh --branch-name=${BRANCH_NAME} --output-dir=tests/CI/output/Build --cache-dir=/srv/cache"</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%);">+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ artifacts: "tests/CI/output/Build/*"</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%);">+ stage ("WikiDocs") {</span><br><span style="color: hsl(120, 100%, 40%);">+ when {</span><br><span style="color: hsl(120, 100%, 40%);">+ expression { jobConfig.wikiDocs.publish }</span><br><span style="color: hsl(120, 100%, 40%);">+ not {</span><br><span style="color: hsl(120, 100%, 40%);">+ triggeredBy 'BranchIndexingCause'</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%);">+ steps { script {</span><br><span style="color: hsl(120, 100%, 40%);">+ dockerImage.inside(dockerOptions + " --name ${buildTag}-wikidocs") {</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%);">+ 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: "tests/CI/output/publish-docs"],</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%);">+ honorRefspec: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ shallow: false</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: jobConfig.wikiDocs.gitURL]]</span><br><span style="color: hsl(120, 100%, 40%);">+ ]</span><br><span style="color: hsl(120, 100%, 40%);">+ sh "./tests/CI/publishAsteriskDocs.sh --user-group=jenkins:users --branch-name=${BRANCH_NAME} --wiki-doc-branch-regex=\"${jobConfig.wikiDocs.branchRegex}\""</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%);">+ stage ("UnitTests") {</span><br><span style="color: hsl(120, 100%, 40%);">+ when {</span><br><span style="color: hsl(120, 100%, 40%);">+ expression { jobConfig.unitTests.run }</span><br><span style="color: hsl(120, 100%, 40%);">+ not {</span><br><span style="color: hsl(120, 100%, 40%);">+ triggeredBy 'BranchIndexingCause'</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%);">+ steps { script {</span><br><span style="color: hsl(120, 100%, 40%);">+ dockerImage.inside(dockerOptions + " --name ${buildTag}-unittests") {</span><br><span style="color: hsl(120, 100%, 40%);">+ def outputdir = "tests/CI/output/UnitTests"</span><br><span style="color: hsl(120, 100%, 40%);">+ def outputfile = "${outputdir}/unittests-results.xml"</span><br><span style="color: hsl(120, 100%, 40%);">+</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%);">+ sh "tests/CI/runUnittests.sh --user-group=jenkins:users --output-dir='${outputdir}' --output-xml='${outputfile}' --unittest-command='${jobConfig.unitTests.testCommand}'"</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: "${outputdir}/**"</span><br><span style="color: hsl(120, 100%, 40%);">+ junit testResults: outputfile,</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%);">+ }}</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%);">+ /* Testsuite Tests</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * When jobConfig.testsuite.run is true, load the JSON file specified by</span><br><span style="color: hsl(120, 100%, 40%);">+ * jobConfig.testsuite.configFile (default "testsuiteConfig") and spin off a</span><br><span style="color: hsl(120, 100%, 40%);">+ * separate docker container for each testGroup contained therein that also</span><br><span style="color: hsl(120, 100%, 40%);">+ * has its "enabled" property set to true.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * If a testGroup has a customTests child, the specified custom tests repo</span><br><span style="color: hsl(120, 100%, 40%);">+ * will be cloned into "<groupDir>/tests/custom" and can be referenced as</span><br><span style="color: hsl(120, 100%, 40%);">+ * any other testsuite test.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Example testsuiteConfig file:</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%);">+ * testGroups: [</span><br><span style="color: hsl(120, 100%, 40%);">+ * {</span><br><span style="color: hsl(120, 100%, 40%);">+ * name: "ari1-mwi",</span><br><span style="color: hsl(120, 100%, 40%);">+ * enabled: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ * dir: "tests/CI/output/ari1",</span><br><span style="color: hsl(120, 100%, 40%);">+ * runTestsuiteOptions: "--test-timeout=180",</span><br><span style="color: hsl(120, 100%, 40%);">+ * testcmd: "--test-regex=tests/rest_api --test-regex=tests/channels/pjsip/.*mwi"</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%);">+ * name: "custom1",</span><br><span style="color: hsl(120, 100%, 40%);">+ * enabled: false,</span><br><span style="color: hsl(120, 100%, 40%);">+ * dir: "tests/CI/output/custom1",</span><br><span style="color: hsl(120, 100%, 40%);">+ * runTestsuiteOptions: "--test-timeout=180",</span><br><span style="color: hsl(120, 100%, 40%);">+ * testcmd: "--test-regex=tests/custom/tests/stress",</span><br><span style="color: hsl(120, 100%, 40%);">+ * customTests: {</span><br><span style="color: hsl(120, 100%, 40%);">+ * branch: "master",</span><br><span style="color: hsl(120, 100%, 40%);">+ * gitURL: "http://somehost/private-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%);">+ * ]</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%);">+ stage("Testsuite") {</span><br><span style="color: hsl(120, 100%, 40%);">+ when {</span><br><span style="color: hsl(120, 100%, 40%);">+ expression { jobConfig.testsuite.run }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ steps { script {</span><br><span style="color: hsl(120, 100%, 40%);">+ testConfig = [</span><br><span style="color: hsl(120, 100%, 40%);">+ testGroups: [],</span><br><span style="color: hsl(120, 100%, 40%);">+ ]</span><br><span style="color: hsl(120, 100%, 40%);">+ def tempTestConfig</span><br><span style="color: hsl(120, 100%, 40%);">+ configFileProvider([configFile(fileId: jobConfig.testsuite.configFile, variable: 'TESTSUITE_CONFIG_FILE')]) {</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Retrieved test config file from ${env.TESTSUITE_CONFIG_FILE}"</span><br><span style="color: hsl(120, 100%, 40%);">+ tempTestConfig = readJSON file: env.TESTSUITE_CONFIG_FILE</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ merge(testConfig, tempTestConfig)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ tasks = [ : ]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ testConfig.testGroups.each {</span><br><span style="color: hsl(120, 100%, 40%);">+ def testGroup = it</span><br><span style="color: hsl(120, 100%, 40%);">+ tasks[testGroup.name] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ dockerImage.inside("${dockerOptions} --name ${buildTag}-${testGroup.name}") {</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 ${testGroup.dir} || : "</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: "${BRANCH_NAME}"]],</span><br><span style="color: hsl(120, 100%, 40%);">+ extensions: [</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'RelativeTargetDirectory', relativeTargetDir: testGroup.dir],</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: 100,</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: jobConfig.testsuite.gitURL]]</span><br><span style="color: hsl(120, 100%, 40%);">+ ]</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "Test Custom Config: ${testGroup.customTests.toString()}"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (testGroup.customTests && testGroup.customTests?.branch && testGroup.customTests?.gitURL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ checkout scm: [$class: 'GitSCM',</span><br><span style="color: hsl(120, 100%, 40%);">+ branches: [[name: testGroup.customTests.branch]],</span><br><span style="color: hsl(120, 100%, 40%);">+ extensions: [</span><br><span style="color: hsl(120, 100%, 40%);">+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "${testGroup.dir}/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: 100,</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: testGroup.customTests.gitURL]]</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 ${testGroup.runTestsuiteOptions} --testsuite-dir='${testGroup.dir}' --testsuite-command='${testGroup.testcmd}'"</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%);">+ archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: true,</span><br><span style="color: hsl(120, 100%, 40%);">+ artifacts: "${testGroup.dir}/asterisk-test-suite-report.xml, ${testGroup.dir}/logs/**, ${testGroup.dir}/core*.txt"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ junit testResults: "${testGroup.dir}/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%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ parallel tasks</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%);">+ script {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (jobConfig.jobCleanup.cleanupWorkspace) {</span><br><span style="color: hsl(120, 100%, 40%);">+ cleanWs deleteDirs: true, notFailBuild: false</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%);">+ 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/+/13927">change 13927</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/+/13927"/><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: Id9d22a778a1916b666e0e700af2b9f1bacda0852 </div>
<div style="display:none"> Gerrit-Change-Number: 13927 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>