2016-11-17 01:06:17 -05:00
|
|
|
// Rook build for Jenkins Pipelines
|
|
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
pipeline {
|
2017-09-19 01:10:50 -07:00
|
|
|
parameters {
|
|
|
|
|
booleanParam(defaultValue: true, description: 'Execute pipeline?', name: 'shouldBuild')
|
|
|
|
|
booleanParam(defaultValue: false, description: 'Run Only Smoke Test', name: 'smokeOnly')
|
|
|
|
|
|
|
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
agent { label 'ec2-stateful' }
|
2016-11-18 23:57:04 -05:00
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
options {
|
2017-06-26 21:52:06 -07:00
|
|
|
disableConcurrentBuilds()
|
2017-07-07 10:58:20 -07:00
|
|
|
timeout(time: 2, unit: 'HOURS')
|
2017-06-26 20:04:53 -07:00
|
|
|
timestamps()
|
|
|
|
|
}
|
2017-03-07 01:04:08 -08:00
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
stages {
|
2017-09-19 01:10:50 -07:00
|
|
|
stage('Pre Build check'){
|
|
|
|
|
when { branch "PR-*" }
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
pr_number = sh (script: "echo ${env.BRANCH_NAME} | grep -o -E '[0-9]+' ",returnStdout: true)
|
|
|
|
|
def json = sh (script: "curl -s https://api.github.com/repos/rook/rook/pulls/${pr_number}", returnStdout: true).trim()
|
|
|
|
|
def body = evaluateJson(json,'${json.body}')
|
|
|
|
|
if (body.contains("[skip ci]")) {
|
|
|
|
|
echo ("'[skip ci]' spotted in PR body text. Aborting.")
|
|
|
|
|
env.shouldBuild = "false"
|
2017-10-18 09:06:01 -07:00
|
|
|
}
|
|
|
|
|
if (body.contains("[skip tests]")) {
|
|
|
|
|
env.shouldTest = "false"
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
if (body.contains("[smoke only]")) {
|
|
|
|
|
env.smokeOnly = "true"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
stage('Build') {
|
2017-09-19 01:10:50 -07:00
|
|
|
when {
|
|
|
|
|
expression {
|
2017-09-21 21:59:05 -07:00
|
|
|
return env.shouldBuild != "false"
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
steps {
|
2017-10-24 12:44:18 -07:00
|
|
|
sh 'build/run make -j\$(nproc) build.all'
|
2017-03-23 20:01:31 -04:00
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
}
|
|
|
|
|
stage('Unit Tests') {
|
2017-09-19 01:10:50 -07:00
|
|
|
when {
|
|
|
|
|
expression {
|
2017-09-21 21:59:05 -07:00
|
|
|
return env.shouldBuild != "false"
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
steps {
|
2017-06-26 21:52:06 -07:00
|
|
|
sh 'build/run make -j\$(nproc) test'
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-15 00:15:51 -07:00
|
|
|
|
|
|
|
|
stage('Integration Tests') {
|
2017-09-19 01:10:50 -07:00
|
|
|
when {
|
|
|
|
|
expression {
|
2017-10-18 09:06:01 -07:00
|
|
|
return env.shouldBuild != "false" && env.shouldTest != "false"
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
}
|
2017-07-15 00:15:51 -07:00
|
|
|
steps{
|
2017-08-24 14:55:01 -07:00
|
|
|
sh 'cat _output/version | xargs tests/scripts/makeTestImages.sh save amd64'
|
|
|
|
|
stash name: 'repo-amd64',includes: 'rook-amd64.tar,build/common.sh,_output/tests/linux_amd64/,_output/charts/,tests/scripts/'
|
2017-07-15 00:15:51 -07:00
|
|
|
script{
|
|
|
|
|
def data = [
|
2017-11-22 01:28:18 -05:00
|
|
|
"gce_1.6.1": "v1.6.1",
|
|
|
|
|
"gce_1.6": "v1.6.13",
|
|
|
|
|
"aws_1.7": "v1.7.11",
|
|
|
|
|
"aws_1.8": "v1.8.5"
|
2017-07-15 00:15:51 -07:00
|
|
|
]
|
|
|
|
|
testruns = [:]
|
|
|
|
|
for (kv in mapToList(data)) {
|
|
|
|
|
testruns[kv[0]] = RunIntegrationTest(kv[0], kv[1])
|
|
|
|
|
}
|
2017-08-09 17:34:10 -07:00
|
|
|
try{
|
|
|
|
|
parallel testruns
|
|
|
|
|
}
|
2017-08-01 15:26:11 -07:00
|
|
|
|
2017-08-09 17:34:10 -07:00
|
|
|
finally{
|
|
|
|
|
sh "build/run go get -u -f github.com/jstemmer/go-junit-report"
|
|
|
|
|
for (kv in mapToList(data)) {
|
|
|
|
|
unstash "${kv[0]}_${kv[1]}_result"
|
|
|
|
|
sh "cat _output/tests/${kv[0]}_${kv[1]}_integrationTests.log | _output/go-junit-report > _output/tests/${kv[0]}_${kv[1]}_integrationTests.xml"
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-15 00:15:51 -07:00
|
|
|
}
|
2017-03-23 20:01:31 -04:00
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
}
|
|
|
|
|
stage('Publish') {
|
2017-09-19 01:10:50 -07:00
|
|
|
when {
|
|
|
|
|
expression {
|
2017-10-18 09:06:01 -07:00
|
|
|
return env.shouldBuild != "false" && env.shouldTest != "false"
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
environment {
|
|
|
|
|
DOCKER = credentials('rook-docker-hub')
|
|
|
|
|
QUAY = credentials('rook-quay-io')
|
|
|
|
|
AWS = credentials('rook-jenkins-aws')
|
2017-08-04 13:25:48 -07:00
|
|
|
GIT = credentials('rook-github')
|
2017-03-23 20:01:31 -04:00
|
|
|
}
|
2017-06-26 20:04:53 -07:00
|
|
|
steps {
|
|
|
|
|
sh 'docker login -u="${DOCKER_USR}" -p="${DOCKER_PSW}"'
|
|
|
|
|
sh 'docker login -u="${QUAY_USR}" -p="${QUAY_PSW}" quay.io'
|
2017-08-04 13:25:48 -07:00
|
|
|
sh 'build/run make -j\$(nproc) -C build/release build BRANCH_NAME=${BRANCH_NAME} GIT_API_TOKEN=${GIT_PSW}'
|
|
|
|
|
sh 'build/run make -j\$(nproc) -C build/release publish BRANCH_NAME=${BRANCH_NAME} AWS_ACCESS_KEY_ID=${AWS_USR} AWS_SECRET_ACCESS_KEY=${AWS_PSW} GIT_API_TOKEN=${GIT_PSW}'
|
2017-07-20 16:00:40 -07:00
|
|
|
sh '[ "${BRANCH_NAME}" != "master" ] || build/run make -j\$(nproc) -C build/release promote BRANCH_NAME=master CHANNEL=master AWS_ACCESS_KEY_ID=${AWS_USR} AWS_SECRET_ACCESS_KEY=${AWS_PSW}'
|
2017-06-26 20:04:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post {
|
|
|
|
|
always {
|
2017-06-26 21:52:06 -07:00
|
|
|
archive '_output/tests/*'
|
|
|
|
|
junit allowEmptyResults: true, keepLongStdio: true, testResults: '_output/tests/*.xml'
|
2017-06-29 18:27:33 -07:00
|
|
|
sh 'make -j\$(nproc) clean'
|
|
|
|
|
sh 'make -j\$(nproc) prune PRUNE_HOURS=48 PRUNE_KEEP=48'
|
|
|
|
|
sh 'make -j\$(nproc) -C build/release clean'
|
2017-11-15 13:58:55 -08:00
|
|
|
notifySlack(currentBuild.result)
|
2017-06-26 20:04:53 -07:00
|
|
|
deleteDir()
|
2016-11-17 01:06:17 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-15 00:15:51 -07:00
|
|
|
def RunIntegrationTest(k, v) {
|
|
|
|
|
return {
|
|
|
|
|
node("${k}") {
|
|
|
|
|
script{
|
|
|
|
|
try{
|
|
|
|
|
withEnv(["KUBE_VERSION=${v}"]){
|
2017-08-01 15:26:11 -07:00
|
|
|
unstash 'repo-amd64'
|
2017-07-15 00:15:51 -07:00
|
|
|
echo "running tests on k8s version ${v}"
|
|
|
|
|
sh 'tests/scripts/makeTestImages.sh load amd64'
|
2017-08-01 15:26:11 -07:00
|
|
|
sh "tests/scripts/kubeadm.sh up"
|
2017-08-24 14:55:01 -07:00
|
|
|
sh '''#!/bin/bash
|
|
|
|
|
export KUBECONFIG=$HOME/admin.conf
|
|
|
|
|
tests/scripts/helm.sh up'''
|
2017-08-01 15:26:11 -07:00
|
|
|
try{
|
2017-09-19 01:10:50 -07:00
|
|
|
if ("${env.smokeOnly}" == "true") {
|
|
|
|
|
echo "Running Smoke Tests"
|
|
|
|
|
sh '''#!/bin/bash
|
|
|
|
|
set -o pipefail
|
|
|
|
|
export KUBECONFIG=$HOME/admin.conf
|
|
|
|
|
kubectl config view
|
2017-10-26 22:15:46 -07:00
|
|
|
_output/tests/linux_amd64/integration -test.v -test.timeout 600s -test.run SmokeSuite --host_type '''+"${k}"+''' 2>&1 | tee _output/tests/integrationTests.log'''
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "Running full regression"
|
2017-08-01 15:26:11 -07:00
|
|
|
sh '''#!/bin/bash
|
2017-09-19 01:10:50 -07:00
|
|
|
set -o pipefail
|
|
|
|
|
export KUBECONFIG=$HOME/admin.conf
|
|
|
|
|
kubectl config view
|
2017-12-29 00:33:36 -08:00
|
|
|
_output/tests/linux_amd64/integration -test.v -test.timeout 2400s --host_type '''+"${k}"+''' 2>&1 | tee _output/tests/integrationTests.log'''
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
2017-08-01 15:26:11 -07:00
|
|
|
}
|
|
|
|
|
finally{
|
2017-09-06 14:37:55 -07:00
|
|
|
sh '''#!/bin/bash
|
|
|
|
|
export KUBECONFIG=$HOME/admin.conf
|
|
|
|
|
tests/scripts/helm.sh clean || true'''
|
2017-08-01 15:26:11 -07:00
|
|
|
sh "mv _output/tests/integrationTests.log _output/tests/${k}_${v}_integrationTests.log"
|
2017-08-09 17:34:10 -07:00
|
|
|
stash name: "${k}_${v}_result",includes : "_output/tests/${k}_${v}_integrationTests.log"
|
2017-08-01 15:26:11 -07:00
|
|
|
}
|
2017-07-15 00:15:51 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally{
|
2017-08-01 15:26:11 -07:00
|
|
|
archive '_output/tests/*.log'
|
2017-07-15 00:15:51 -07:00
|
|
|
deleteDir()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Required due to JENKINS-27421
|
|
|
|
|
@NonCPS
|
|
|
|
|
List<List<?>> mapToList(Map map) {
|
|
|
|
|
return map.collect { it ->[it.key, it.value]}
|
2017-09-19 01:10:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NonCPS
|
|
|
|
|
def evaluateJson(String json, String gpath){
|
|
|
|
|
//parse json
|
|
|
|
|
def ojson = new groovy.json.JsonSlurper().parseText(json)
|
|
|
|
|
//evaluate gpath as a gstring template where $json is a parsed json parameter
|
|
|
|
|
return new groovy.text.GStringTemplateEngine().createTemplate(gpath).make(json:ojson).toString()
|
2017-11-15 13:58:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def notifySlack(String buildStatus) {
|
|
|
|
|
|
|
|
|
|
// build status of null means successful
|
|
|
|
|
buildStatus = buildStatus ?: 'SUCCESS'
|
|
|
|
|
|
|
|
|
|
// Default values
|
|
|
|
|
def colorCode = '#FF0000'
|
|
|
|
|
def summary = "@channel ${buildStatus}: $JOB_NAME: \n<$BUILD_URL|Build #$BUILD_NUMBER> - $currentBuild.displayName"
|
|
|
|
|
|
|
|
|
|
// Override default values based on build status
|
|
|
|
|
if (buildStatus != 'SUCCESS') {
|
|
|
|
|
// Send notifications to channel on non success builds only
|
|
|
|
|
if (env.BRANCH_NAME == "master" || env.BRANCH_NAME.contains("release")){
|
|
|
|
|
slackSend (color: colorCode, message: summary)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|