2019-10-31 14:30:55 +08:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
2019-10-28 10:19:07 +08:00
|
|
|
String cron_timezone = "TZ=Asia/Shanghai"
|
2019-10-28 10:29:59 +08:00
|
|
|
String cron_string = BRANCH_NAME == "master" ? "H 0 * * * " : ""
|
2019-10-26 14:35:53 +08:00
|
|
|
|
2019-10-16 21:20:21 +08:00
|
|
|
pipeline {
|
|
|
|
agent none
|
|
|
|
|
2019-10-28 10:19:07 +08:00
|
|
|
triggers {
|
2019-10-28 10:29:59 +08:00
|
|
|
cron """${cron_timezone}
|
|
|
|
${cron_string}"""
|
2019-10-28 10:19:07 +08:00
|
|
|
}
|
2019-10-26 11:25:08 +08:00
|
|
|
|
2019-10-16 21:20:21 +08:00
|
|
|
options {
|
|
|
|
timestamps()
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters{
|
2019-11-28 14:39:42 +08:00
|
|
|
choice choices: ['Release', 'Debug'], description: 'Build Type', name: 'BUILD_TYPE'
|
2019-10-19 15:58:06 +08:00
|
|
|
string defaultValue: 'registry.zilliz.com', description: 'DOCKER REGISTRY URL', name: 'DOKCER_REGISTRY_URL', trim: true
|
2019-10-16 21:20:21 +08:00
|
|
|
string defaultValue: 'ba070c98-c8cc-4f7c-b657-897715f359fc', description: 'DOCKER CREDENTIALS ID', name: 'DOCKER_CREDENTIALS_ID', trim: true
|
2019-12-10 11:09:16 +08:00
|
|
|
string defaultValue: 'http://192.168.1.201/artifactory/milvus', description: 'JFROG ARTFACTORY URL', name: 'JFROG_ARTFACTORY_URL', trim: true
|
2019-10-19 15:58:06 +08:00
|
|
|
string defaultValue: '1a527823-d2b7-44fd-834b-9844350baf14', description: 'JFROG CREDENTIALS ID', name: 'JFROG_CREDENTIALS_ID', trim: true
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
PROJECT_NAME = "milvus"
|
2019-12-03 10:58:56 +08:00
|
|
|
MILVUS_ROOT_PATH="/var/lib"
|
|
|
|
MILVUS_INSTALL_PREFIX="${env.MILVUS_ROOT_PATH}/${env.PROJECT_NAME}"
|
2019-10-16 21:20:21 +08:00
|
|
|
LOWER_BUILD_TYPE = params.BUILD_TYPE.toLowerCase()
|
2019-11-28 17:14:59 +08:00
|
|
|
SEMVER = "${BRANCH_NAME.contains('/') ? BRANCH_NAME.substring(BRANCH_NAME.lastIndexOf('/') + 1) : BRANCH_NAME}"
|
|
|
|
PIPELINE_NAME = "${env.JOB_NAME.contains('/') ? env.JOB_NAME.getAt(0..(env.JOB_NAME.indexOf('/') - 1)) : env.JOB_NAME}"
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2019-12-16 14:12:31 +08:00
|
|
|
stage ('Milvus Build and Test') {
|
|
|
|
matrix {
|
|
|
|
agent none
|
|
|
|
axes {
|
|
|
|
axis {
|
|
|
|
name 'OS_NAME'
|
|
|
|
values 'ubuntu18.04', 'centos7'
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
|
2019-12-16 14:12:31 +08:00
|
|
|
axis {
|
|
|
|
name 'CPU_ARCH'
|
|
|
|
values 'amd64'
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
|
2019-12-16 14:12:31 +08:00
|
|
|
axis {
|
2019-12-18 17:19:15 +08:00
|
|
|
name 'BINARY_VERSION'
|
2019-12-16 14:12:31 +08:00
|
|
|
values 'gpu', 'cpu'
|
|
|
|
}
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stages {
|
2019-12-16 15:43:46 +08:00
|
|
|
stage("Milvus CI") {
|
2019-12-16 14:50:10 +08:00
|
|
|
environment {
|
|
|
|
PACKAGE_VERSION = VersionNumber([
|
2019-12-18 17:19:15 +08:00
|
|
|
versionNumberString : '${SEMVER}-${BINARY_VERSION}-${OS_NAME}-${CPU_ARCH}-${LOWER_BUILD_TYPE}-${BUILD_DATE_FORMATTED, "yyyyMMdd"}-${BUILDS_TODAY}'
|
2019-12-16 14:50:10 +08:00
|
|
|
]);
|
2019-12-18 17:19:15 +08:00
|
|
|
DOCKER_VERSION = "${SEMVER}-${BINARY_VERSION}-${OS_NAME}-${LOWER_BUILD_TYPE}"
|
2019-12-16 14:50:10 +08:00
|
|
|
}
|
2019-12-16 14:45:18 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stages {
|
2019-12-16 15:41:59 +08:00
|
|
|
stage('Run Build') {
|
2020-01-20 21:05:01 +08:00
|
|
|
when {
|
2020-01-20 22:24:02 +08:00
|
|
|
allOf {
|
|
|
|
anyOf {
|
|
|
|
changeset 'ci/**'
|
|
|
|
changeset 'core/**'
|
|
|
|
changeset 'docker/**'
|
|
|
|
changeset 'test/**'
|
|
|
|
}
|
|
|
|
not {
|
|
|
|
anyOf {
|
|
|
|
changeset '**/*.md'
|
|
|
|
}
|
|
|
|
}
|
2020-01-20 21:05:01 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-16 14:50:10 +08:00
|
|
|
agent {
|
|
|
|
kubernetes {
|
2019-12-20 15:55:02 +08:00
|
|
|
label "${OS_NAME}-${BINARY_VERSION}-build-${env.PIPELINE_NAME}-${env.BUILD_NUMBER}"
|
2019-12-16 14:50:10 +08:00
|
|
|
defaultContainer 'jnlp'
|
2019-12-18 17:19:15 +08:00
|
|
|
yamlFile "ci/jenkins/pod/milvus-${BINARY_VERSION}-version-${OS_NAME}-build-env-pod.yaml"
|
2019-12-16 14:50:10 +08:00
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
2019-12-16 14:12:31 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stages {
|
2019-12-16 15:41:59 +08:00
|
|
|
stage('Build') {
|
2019-12-16 14:50:10 +08:00
|
|
|
steps {
|
2019-12-18 17:19:15 +08:00
|
|
|
container("milvus-${BINARY_VERSION}-build-env") {
|
2019-12-16 14:50:10 +08:00
|
|
|
script {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/build.groovy"
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-16 14:12:31 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stage('Code Coverage') {
|
|
|
|
steps {
|
2019-12-18 17:19:15 +08:00
|
|
|
container("milvus-${BINARY_VERSION}-build-env") {
|
2019-12-16 14:50:10 +08:00
|
|
|
script {
|
2019-12-18 17:19:15 +08:00
|
|
|
if ("${BINARY_VERSION}" == "gpu") {
|
2019-12-16 16:40:58 +08:00
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/coverage.groovy"
|
|
|
|
} else {
|
|
|
|
echo "Skip Code Coverage"
|
|
|
|
}
|
2019-12-16 14:50:10 +08:00
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stage('Upload Package') {
|
|
|
|
steps {
|
2019-12-18 17:19:15 +08:00
|
|
|
container("milvus-${BINARY_VERSION}-build-env") {
|
2019-12-16 14:50:10 +08:00
|
|
|
script {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/package.groovy"
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 15:41:59 +08:00
|
|
|
stage('Publish docker images') {
|
2020-01-20 21:05:01 +08:00
|
|
|
when {
|
2020-01-20 22:24:02 +08:00
|
|
|
allOf {
|
|
|
|
anyOf {
|
|
|
|
changeset 'ci/**'
|
|
|
|
changeset 'core/**'
|
|
|
|
changeset 'docker/**'
|
|
|
|
changeset 'test/**'
|
|
|
|
}
|
|
|
|
not {
|
|
|
|
anyOf {
|
|
|
|
changeset '**/*.md'
|
|
|
|
}
|
|
|
|
}
|
2020-01-20 21:05:01 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-16 14:50:10 +08:00
|
|
|
agent {
|
|
|
|
kubernetes {
|
2019-12-20 15:55:02 +08:00
|
|
|
label "${OS_NAME}-${BINARY_VERSION}-publish-${env.PIPELINE_NAME}-${env.BUILD_NUMBER}"
|
2019-12-16 14:50:10 +08:00
|
|
|
defaultContainer 'jnlp'
|
|
|
|
yamlFile 'ci/jenkins/pod/docker-pod.yaml'
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stages {
|
|
|
|
stage('Publish') {
|
|
|
|
steps {
|
|
|
|
container('publish-images') {
|
|
|
|
script {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/publishImages.groovy"
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
|
2019-12-16 15:41:59 +08:00
|
|
|
stage('Deploy to Development') {
|
2020-01-20 21:05:01 +08:00
|
|
|
when {
|
2020-01-20 22:24:02 +08:00
|
|
|
allOf {
|
|
|
|
anyOf {
|
|
|
|
changeset 'ci/**'
|
|
|
|
changeset 'core/**'
|
|
|
|
changeset 'docker/**'
|
|
|
|
changeset 'test/**'
|
|
|
|
}
|
|
|
|
not {
|
|
|
|
anyOf {
|
|
|
|
changeset '**/*.md'
|
|
|
|
}
|
|
|
|
}
|
2020-01-20 21:05:01 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-16 14:50:10 +08:00
|
|
|
environment {
|
2019-12-26 10:33:05 +08:00
|
|
|
FROMAT_SEMVER = "${env.SEMVER}".replaceAll("\\.", "-").replaceAll("_", "-")
|
|
|
|
FORMAT_OS_NAME = "${OS_NAME}".replaceAll("\\.", "-").replaceAll("_", "-")
|
2019-12-18 17:19:15 +08:00
|
|
|
HELM_RELEASE_NAME = "${env.PIPELINE_NAME}-${env.FROMAT_SEMVER}-${env.BUILD_NUMBER}-single-${FORMAT_OS_NAME}-${BINARY_VERSION}".toLowerCase()
|
2019-12-16 14:50:10 +08:00
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
agent {
|
|
|
|
kubernetes {
|
2019-12-20 15:55:02 +08:00
|
|
|
label "${OS_NAME}-${BINARY_VERSION}-dev-test-${env.PIPELINE_NAME}-${env.BUILD_NUMBER}"
|
2019-12-16 14:50:10 +08:00
|
|
|
defaultContainer 'jnlp'
|
|
|
|
yamlFile 'ci/jenkins/pod/testEnvironment.yaml'
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
stages {
|
2019-12-16 15:41:59 +08:00
|
|
|
stage('Deploy to Dev') {
|
2019-12-16 14:50:10 +08:00
|
|
|
steps {
|
|
|
|
container('milvus-test-env') {
|
|
|
|
script {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/deploySingle2Dev.groovy"
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 15:41:59 +08:00
|
|
|
stage('Dev Test') {
|
2019-12-16 14:50:10 +08:00
|
|
|
steps {
|
|
|
|
container('milvus-test-env') {
|
|
|
|
script {
|
|
|
|
boolean isNightlyTest = isTimeTriggeredBuild()
|
|
|
|
if (isNightlyTest) {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/singleDevNightlyTest.groovy"
|
|
|
|
} else {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/singleDevTest.groovy"
|
|
|
|
}
|
2019-11-15 15:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
2019-12-18 15:54:13 +08:00
|
|
|
|
2019-12-16 14:50:10 +08:00
|
|
|
post {
|
2019-12-18 15:59:50 +08:00
|
|
|
cleanup {
|
2019-12-16 14:50:10 +08:00
|
|
|
container('milvus-test-env') {
|
|
|
|
script {
|
|
|
|
load "${env.WORKSPACE}/ci/jenkins/step/cleanupSingleDev.groovy"
|
|
|
|
}
|
2019-12-16 14:45:18 +08:00
|
|
|
}
|
2019-12-18 15:54:13 +08:00
|
|
|
}
|
2019-12-16 14:45:18 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 09:59:49 +08:00
|
|
|
post {
|
2020-01-19 18:03:45 +08:00
|
|
|
unsuccessful {
|
2020-01-17 09:59:49 +08:00
|
|
|
script {
|
|
|
|
boolean isNightlyTest = isTimeTriggeredBuild()
|
2020-01-19 18:03:45 +08:00
|
|
|
if (isNightlyTest) {
|
2020-01-17 09:59:49 +08:00
|
|
|
// Send an email only if the build status has changed from green/unstable to red
|
|
|
|
emailext subject: '$DEFAULT_SUBJECT',
|
|
|
|
body: '$DEFAULT_CONTENT',
|
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'DevelopersRecipientProvider'],
|
|
|
|
[$class: 'RequesterRecipientProvider']
|
|
|
|
],
|
|
|
|
replyTo: '$DEFAULT_REPLYTO',
|
|
|
|
to: '$DEFAULT_RECIPIENTS'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 21:20:21 +08:00
|
|
|
}
|
|
|
|
|
2019-10-26 15:52:35 +08:00
|
|
|
boolean isTimeTriggeredBuild() {
|
2019-10-26 17:31:54 +08:00
|
|
|
if (currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').size() != 0) {
|
|
|
|
return true
|
2019-10-26 15:52:35 +08:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|