milvus/ci/jenkins/Jenkinsfile

203 lines
9.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env groovy
String cron_timezone = "TZ=Asia/Shanghai"
String cron_string = BRANCH_NAME == "master" ? "H 0 * * * " : ""
pipeline {
agent none
triggers {
cron """${cron_timezone}
${cron_string}"""
}
options {
timestamps()
}
parameters{
2019-11-28 14:39:42 +08:00
choice choices: ['Release', 'Debug'], description: 'Build Type', name: 'BUILD_TYPE'
string defaultValue: 'registry.zilliz.com', description: 'DOCKER REGISTRY URL', name: 'DOKCER_REGISTRY_URL', trim: true
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
string defaultValue: '1a527823-d2b7-44fd-834b-9844350baf14', description: 'JFROG CREDENTIALS ID', name: 'JFROG_CREDENTIALS_ID', trim: true
}
environment {
PROJECT_NAME = "milvus"
MILVUS_ROOT_PATH="/var/lib"
MILVUS_INSTALL_PREFIX="${env.MILVUS_ROOT_PATH}/${env.PROJECT_NAME}"
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}"
}
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-12-16 14:12:31 +08:00
axis {
name 'CPU_ARCH'
values 'amd64'
}
2019-12-16 14:12:31 +08:00
axis {
name 'BINRARY_VERSION'
values 'gpu', 'cpu'
}
}
stages {
stage ("${OS_NAME} ${CPU_ARCH} ${BINRARY_VERSION}"){
environment {
PACKAGE_VERSION = VersionNumber([
versionNumberString : '${SEMVER}-${BINRARY_VERSION}-${OS_NAME}-${CPU_ARCH}-${LOWER_BUILD_TYPE}-${BUILD_DATE_FORMATTED, "yyyyMMdd"}-${BUILDS_TODAY}'
]);
DOCKER_VERSION = "${SEMVER}-${BINRARY_VERSION}-${OS_NAME}-${LOWER_BUILD_TYPE}"
}
2019-11-15 15:36:15 +08:00
2019-12-16 14:12:31 +08:00
stages {
stage ("Run Build") {
agent {
kubernetes {
label "${BINRARY_VERSION}-build"
defaultContainer 'jnlp'
yamlFile "ci/jenkins/pod/milvus-${BINRARY_VERSION}-version-${OS_NAME}-build-env-pod.yaml"
2019-11-15 15:36:15 +08:00
}
}
2019-12-16 14:12:31 +08:00
stages {
stage ('Build') {
steps {
container("milvus-${BINRARY_VERSION}-build-env") {
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
stage('Code Coverage') {
steps {
container("milvus-${BINRARY_VERSION}-build-env") {
script {
load "${env.WORKSPACE}/ci/jenkins/step/coverage.groovy"
}
2019-11-15 15:36:15 +08:00
}
}
}
2019-11-15 15:36:15 +08:00
2019-12-16 14:12:31 +08:00
stage('Upload Package') {
steps {
container("milvus-${BINRARY_VERSION}-build-env") {
script {
load "${env.WORKSPACE}/ci/jenkins/step/package.groovy"
}
2019-11-15 15:36:15 +08:00
}
}
}
}
}
2019-12-16 14:12:31 +08:00
stage("Publish docker images") {
agent {
kubernetes {
label "${BINRARY_VERSION}-publish"
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/docker-pod.yaml'
2019-11-15 15:36:15 +08:00
}
}
2019-12-16 14:12:31 +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-12-16 14:12:31 +08:00
stage("Deploy to Development") {
environment {
FROMAT_SEMVER = "${env.SEMVER}".replaceAll("\\.", "-")
HELM_RELEASE_NAME = "${env.PIPELINE_NAME}-${env.FROMAT_SEMVER}-${env.BUILD_NUMBER}-single-${BINRARY_VERSION}".toLowerCase()
2019-11-15 15:36:15 +08:00
}
2019-12-16 14:12:31 +08:00
agent {
kubernetes {
label "${BINRARY_VERSION}-dev-test"
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/testEnvironment.yaml'
}
}
2019-12-16 14:12:31 +08:00
stages {
stage("Deploy to Dev") {
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/deploySingle2Dev.groovy"
}
2019-11-15 15:36:15 +08:00
}
}
}
2019-11-15 15:36:15 +08:00
2019-12-16 14:12:31 +08:00
stage("Dev Test") {
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-12-16 14:12:31 +08:00
stage ("Cleanup Dev") {
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/cleanupSingleDev.groovy"
2019-11-15 15:36:15 +08:00
}
}
}
}
}
2019-12-16 14:12:31 +08:00
post {
unsuccessful {
2019-11-15 15:36:15 +08:00
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/cleanupSingleDev.groovy"
}
}
}
}
}
}
}
}
}
}
}
}
boolean isTimeTriggeredBuild() {
if (currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').size() != 0) {
return true
}
return false
}