mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-06 18:03:34 +00:00
The original clone depth of 10 was causing the need to rebase changes whose parent was older than the 10 commits. The clone depth has been increased to 100. Workspace cleanup was only happening for successful builds which wasn't enough to keep the 8G workspace in-memory drives on the docker slaves from filling up. Now the workspaces are cleaned up after every build regardless of success/failure. If you need to preserve builds temporarily, you can log into Jenkins/Manage Jenkins/Configure System and change the CLEANUP_WS_* environment variable for the job type you're troubleshooting to "FALSE". Change-Id: I0d7366e87cea714e5dbc9488caf718802fce75ca
147 lines
4.8 KiB
Plaintext
147 lines
4.8 KiB
Plaintext
/*
|
|
* 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
|
|
* you can't do that in a delcarative pipeline.
|
|
*/
|
|
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]
|
|
}
|
|
|
|
pipeline {
|
|
options {
|
|
ansiColor('gnome-terminal')
|
|
throttle(['asterisk-ref-debug'])
|
|
timestamps()
|
|
timeout(time: timeoutTime, unit: timeoutUnits)
|
|
}
|
|
triggers {
|
|
cron 'H H(0-4) * * 0'
|
|
}
|
|
|
|
agent {
|
|
/* All of the stages need to be performed on a docker host */
|
|
label "asterisk-ref-debug"
|
|
}
|
|
|
|
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 -0 | sort -z | tr '\\0' '\\n'"
|
|
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/Testsuite"
|
|
|
|
manager.createSummary("/plugin/workflow-job/images/48x48/pipelinejob.png").appendText("Docker Image: ${randomImage}", false)
|
|
def img = docker.image(randomImage)
|
|
img.pull()
|
|
|
|
stage ("Build") {
|
|
img.inside(dockerOptions + " --name ${bt}-build") {
|
|
echo 'Building..'
|
|
env.CCACHE_DIR = "/srv/cache/ccache"
|
|
sh "./tests/CI/buildAsterisk.sh --ref-debug --branch-name=${BRANCH_NAME} --output-dir=${outputdir} --cache-dir=/srv/cache"
|
|
|
|
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
|
|
def testsuiteUrl = env.GIT_URL.replaceAll(/\/[^\/]+$/, "/testsuite")
|
|
|
|
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: "${BRANCH_NAME}"]],
|
|
extensions: [
|
|
[$class: 'RelativeTargetDirectory', relativeTargetDir: groupDir],
|
|
[$class: 'CloneOption',
|
|
noTags: true,
|
|
depth: 100,
|
|
honorRefspec: true,
|
|
shallow: true
|
|
],
|
|
],
|
|
userRemoteConfigs: [[url: testsuiteUrl]]
|
|
]
|
|
|
|
sh "sudo tests/CI/runTestsuite.sh --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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
parallel parallelTasks
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
cleanup {
|
|
if (env.CLEANUP_WS_REF_DEBUG.toBoolean()) {
|
|
cleanWs deleteDirs: true, notFailBuild: false
|
|
}
|
|
}
|
|
success {
|
|
echo "Reporting ${currentBuild.currentResult} Passed"
|
|
}
|
|
failure {
|
|
echo "Reporting ${currentBuild.currentResult}: Failed: Fatal Error"
|
|
}
|
|
unstable {
|
|
echo "Reporting ${currentBuild.currentResult}: Failed: Tests Failed"
|
|
}
|
|
}
|
|
}
|