milvus/build/ci/jenkins/Jenkinsfile
edward.zeng 9d567c5a36
[skip ci] Allow jenkins ci fail fast (#8390)
Signed-off-by: Edward Zeng <jie.zeng@zilliz.com>
2021-09-23 15:11:55 +08:00

124 lines
5.8 KiB
Groovy

#!/usr/bin/env groovy
int total_timeout_minutes = 120
int e2e_timeout_seconds = 30 * 60
pipeline {
agent none
options {
timestamps()
timeout(time: total_timeout_minutes, unit: 'MINUTES')
buildDiscarder logRotator(artifactDaysToKeepStr: '30')
parallelsAlwaysFailFast()
}
stages {
stage ('E2E Test') {
matrix {
axes {
axis {
name 'MILVUS_SERVER_TYPE'
values 'standalone', 'distributed'
}
axis {
name 'MILVUS_CLIENT'
values 'pymilvus'
}
}
agent {
kubernetes {
label "milvus-e2e-test-kind"
defaultContainer 'main'
yamlFile "build/ci/jenkins/pod/krte.yaml"
customWorkspace '/home/jenkins/agent/workspace'
// We allow this pod to remain active for a while, later jobs can
// reuse cache in previous created nodes.
idleMinutes 120
}
}
environment {
PROJECT_NAME = "milvus"
SEMVER = "${BRANCH_NAME.contains('/') ? BRANCH_NAME.substring(BRANCH_NAME.lastIndexOf('/') + 1) : BRANCH_NAME}"
IMAGE_REPO = "dockerhub-mirror-sh.zilliz.cc/milvusdb"
DOCKER_BUILDKIT = 1
ARTIFACTS = "${env.WORKSPACE}/_artifacts"
}
stages {
stage('Test') {
steps {
container('etcd') {
script {
sh 'ETCDCTL_API=3 etcdctl del "" --from-key=true'
}
}
container('main') {
dir ('tests/scripts') {
script {
sh 'printenv'
def clusterEnabled = "false"
if ("${MILVUS_SERVER_TYPE}" == "distributed") {
clusterEnabled = "true"
}
if ("${MILVUS_CLIENT}" == "pymilvus") {
sh """
MILVUS_CLUSTER_ENABLED=${clusterEnabled} \
./e2e-k8s.sh \
--node-image registry.zilliz.com/kindest/node:v1.20.2 \
--kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \
--install-extra-arg "--set etcd.enabled=false --set externalEtcd.enabled=true --set externalEtcd.endpoints={\$KRTE_POD_IP:2379}" \
--skip-export-logs \
--skip-cleanup \
--test-extra-arg "-x --tags L0 L1" \
--test-timeout ${e2e_timeout_seconds}
"""
} else {
error "Error: Unsupported Milvus client: ${MILVUS_CLIENT}"
}
}
}
}
}
}
}
post {
always {
container('main') {
script {
sh "./tests/scripts/export_logs.sh"
dir("${env.ARTIFACTS}") {
sh "find ./kind -path '*/history/*' -type f | xargs tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-${MILVUS_CLIENT}-e2e-logs.tar.gz --transform='s:^[^/]*/[^/]*/[^/]*/[^/]*/::g' || true"
if ("${MILVUS_CLIENT}" == "pymilvus") {
sh "tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${MILVUS_CLIENT}-pytest-logs.tar.gz ./tests/pytest_logs --remove-files || true"
}
archiveArtifacts artifacts: "**.tar.gz", allowEmptyArchive: true
}
}
}
}
unsuccessful {
container('jnlp') {
script {
def authorEmail = sh returnStdout: true, script: 'git --no-pager show -s --format=\'%ae\' HEAD'
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
recipientProviders: [developers(), culprits()],
replyTo: '$DEFAULT_REPLYTO',
to: "${authorEmail}"
}
}
}
cleanup {
container('main') {
script {
sh "kind delete cluster --name kind -v9 || true"
sh 'find . -name . -o -prune -exec rm -rf -- {} +' /* clean up our workspace */
}
}
}
}
}
}
}
}