From f9077a20d50db4b4cf40a05c9143b77bcc8f17b1 Mon Sep 17 00:00:00 2001 From: Evgeny L Date: Wed, 22 May 2019 19:34:32 +0000 Subject: [PATCH] Add Airship-in-a-Bottle cicd gate jobs Change-Id: I367cae5bae964c7ce0f0427c8bff0d9694e46db7 --- tools/gate/aiab/Jenkinsfile | 54 +++++++++++++++++++++++++++++++++++++ tools/gate/aiab/seed.groovy | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 tools/gate/aiab/Jenkinsfile create mode 100644 tools/gate/aiab/seed.groovy diff --git a/tools/gate/aiab/Jenkinsfile b/tools/gate/aiab/Jenkinsfile new file mode 100644 index 000000000..98d4005be --- /dev/null +++ b/tools/gate/aiab/Jenkinsfile @@ -0,0 +1,54 @@ +// pipeline for treasuremap installation of airship-in-a-bottle, +// more info at http://www.airshipit.org/ + +ARTF_BASE = "cicd/logs/${JOB_NAME}/${BUILD_ID}" + +REPO_URL = 'https://review.opendev.org/airship/treasuremap' +REPO_HOME = '/root/deploy/treasuremap' + +publicNet = 'public' +if (env.AIRSHIP_VM_PUBLIC_NET) { + publicNet = env.AIRSHIP_VM_PUBLIC_NET +} + +vm(flavor: 'm1.xxlarge', artifactoryLogs: true, publicNet: publicNet) { + + stage('Checkout'){ + + sh 'sudo mkdir /root/deploy' + sh 'sudo setfacl -m u:ubuntu:rwx /root/deploy' + sh 'sudo setfacl -m u:ubuntu:rwx /root' + + gerrit.cloneToBranch(REPO_URL, GERRIT_PATCHSET_REVISION, REPO_HOME) + + if(GERRIT_EVENT_TYPE != 'change-merged') { + dir(REPO_HOME) { + gerrit.rebase() + } + } + currentBuild.displayName = "#${BUILD_NUMBER} ${GERRIT_EVENT_TYPE}" + } + + stage('Run Airship') { + dir("${REPO_HOME}/tools/deployment/aiab/dev_single_node"){ + try { + timeout(120){ + sh 'sudo TERM_OPTS=-i ./airship-in-a-bottle.sh -y' + } + } catch (err) { + try { + sh 'sudo debug-report.sh' + def hostname = sh (script: 'hostname', returnStdout: true).trim() + artifactory.upload("debug-${hostname}.tgz", + "${ARTF_BASE}/debug-${hostname}.tgz") + } catch (lerr){ + // pipeline may not yet deployed basic k8s + // cause of the issue will be found in Jenkins console log + print "Failed to publish debug report: ${lerr}" + } + error(err) + } + } + } +} + diff --git a/tools/gate/aiab/seed.groovy b/tools/gate/aiab/seed.groovy new file mode 100644 index 000000000..e343e88b5 --- /dev/null +++ b/tools/gate/aiab/seed.groovy @@ -0,0 +1,52 @@ +JOB_BASE = 'tools/gate/aiab' + +pipelineJob("treasuremap-aiab") { + + logRotator{ + daysToKeep(90) + } + + configure { + node -> node / 'properties' / 'jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl'{ + durationName 'hour' + count '3' + } + } + + triggers { + gerritTrigger { + serverName('ATT-airship-CI') + gerritProjects { + gerritProject { + compareType('PLAIN') + pattern("airship/treasuremap") + branches { + branch { + compareType("ANT") + pattern("**") + } + } + disableStrictForbiddenFileVerification(false) + } + } + triggerOnEvents { + patchsetCreated { + excludeDrafts(false) + excludeTrivialRebase(false) + excludeNoCodeChange(false) + } + changeMerged() + commentAddedContains { + commentAddedCommentContains('^recheck\$') + } + } + } + + definition { + cps { + script(readFileFromWorkspace("${JOB_BASE}/Jenkinsfile")) + sandbox(false) + } + } + } +}