milvus/ci/jenkins/Jenkinsfile

323 lines
15 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env groovy
String cron_timezone = "TZ=Asia/Shanghai"
String cron_string = BRANCH_NAME == "master" ? "H 0 * * * " : ""
2019-11-18 15:49:37 +08:00
cron_string = BRANCH_NAME == "0.6.0" ? "H 1 * * * " : cron_string
pipeline {
agent none
triggers {
cron """${cron_timezone}
${cron_string}"""
}
options {
timestamps()
}
parameters{
choice choices: ['Release', 'Debug'], description: '', 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
string defaultValue: 'http://192.168.1.202/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"
LOWER_BUILD_TYPE = params.BUILD_TYPE.toLowerCase()
SEMVER = "${BRANCH_NAME}"
JOBNAMES = env.JOB_NAME.split('/')
PIPELINE_NAME = "${JOBNAMES[0]}"
}
stages {
2019-11-15 15:36:15 +08:00
stage("Ubuntu 18.04 x86_64") {
environment {
OS_NAME = "ubuntu18.04"
2019-11-15 15:36:15 +08:00
CPU_ARCH = "amd64"
}
2019-11-15 15:36:15 +08:00
parallel {
2019-11-15 17:07:39 +08:00
stage ("GPU Version") {
2019-11-15 15:36:15 +08:00
environment {
2019-11-15 17:07:39 +08:00
BINRARY_VERSION = "gpu"
2019-11-15 15:36:15 +08:00
PACKAGE_VERSION = VersionNumber([
2019-11-15 17:07:39 +08:00
versionNumberString : '${SEMVER}-gpu-${OS_NAME}-${CPU_ARCH}-${LOWER_BUILD_TYPE}-${BUILD_DATE_FORMATTED, "yyyyMMdd"}-${BUILDS_TODAY}'
2019-11-15 15:36:15 +08:00
]);
2019-11-15 17:07:39 +08:00
DOCKER_VERSION = "${SEMVER}-gpu-${OS_NAME}-${LOWER_BUILD_TYPE}"
}
stages {
2019-11-21 10:25:38 +08:00
stage("Run Build") {
2019-11-15 15:36:15 +08:00
agent {
kubernetes {
2019-11-21 15:42:10 +08:00
label "${env.BINRARY_VERSION}-build"
2019-11-15 15:36:15 +08:00
defaultContainer 'jnlp'
2019-11-15 17:07:39 +08:00
yamlFile 'ci/jenkins/pod/milvus-gpu-version-build-env-pod.yaml'
}
}
2019-11-15 15:36:15 +08:00
stages {
2019-11-21 10:25:38 +08:00
stage('Build') {
2019-11-15 15:36:15 +08:00
steps {
2019-11-21 15:42:10 +08:00
container("milvus-${env.BINRARY_VERSION}-build-env") {
2019-11-15 15:36:15 +08:00
script {
load "${env.WORKSPACE}/ci/jenkins/step/build.groovy"
}
}
}
}
2019-11-21 10:25:38 +08:00
stage('Code Coverage') {
2019-11-15 15:36:15 +08:00
steps {
2019-11-21 15:42:10 +08:00
container("milvus-${env.BINRARY_VERSION}-build-env") {
2019-11-15 15:36:15 +08:00
script {
load "${env.WORKSPACE}/ci/jenkins/step/coverage.groovy"
}
}
}
}
2019-11-21 10:25:38 +08:00
stage('Upload Package') {
2019-11-15 15:36:15 +08:00
steps {
2019-11-21 15:42:10 +08:00
container("milvus-${env.BINRARY_VERSION}-build-env") {
2019-11-15 15:36:15 +08:00
script {
load "${env.WORKSPACE}/ci/jenkins/step/package.groovy"
}
}
}
}
}
}
2019-11-15 15:36:15 +08:00
2019-11-21 10:25:38 +08:00
stage("Publish docker images") {
2019-11-15 15:36:15 +08:00
agent {
kubernetes {
2019-11-21 15:42:10 +08:00
label "${env.BINRARY_VERSION}-publish"
2019-11-15 15:36:15 +08:00
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/docker-pod.yaml'
}
}
stages {
2019-11-21 10:25:38 +08:00
stage('Publish') {
2019-11-15 15:36:15 +08:00
steps {
container('publish-images'){
script {
load "${env.WORKSPACE}/ci/jenkins/step/publishImages.groovy"
}
}
}
}
}
}
2019-11-21 10:25:38 +08:00
stage("Deploy to Development") {
2019-11-21 16:49:01 +08:00
environment {
2019-11-23 19:08:19 +08:00
FROMAT_SEMVER = "${env.SEMVER}".replaceAll("\\.", "-")
2019-11-23 11:21:36 +08:00
HELM_RELEASE_NAME = "${env.PIPELINE_NAME}-${env.FROMAT_SEMVER}-${env.BUILD_NUMBER}-single-${env.BINRARY_VERSION}".toLowerCase()
2019-11-21 16:49:01 +08:00
}
2019-11-15 15:36:15 +08:00
agent {
kubernetes {
2019-11-21 15:42:10 +08:00
label "${env.BINRARY_VERSION}-dev-test"
2019-11-15 15:36:15 +08:00
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/testEnvironment.yaml'
}
}
2019-11-15 15:36:15 +08:00
stages {
2019-11-21 10:25:38 +08:00
stage("Deploy to Dev") {
2019-11-15 15:36:15 +08:00
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/deploySingle2Dev.groovy"
}
}
}
}
2019-11-21 10:25:38 +08:00
stage("Dev Test") {
2019-11-15 15:36:15 +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-21 10:25:38 +08:00
stage ("Cleanup Dev") {
2019-11-15 15:36:15 +08:00
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/cleanupSingleDev.groovy"
}
}
}
}
}
post {
unsuccessful {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/cleanupSingleDev.groovy"
}
}
}
}
}
}
}
2019-11-15 17:07:39 +08:00
stage ("CPU Version") {
2019-11-15 15:36:15 +08:00
environment {
2019-11-15 17:07:39 +08:00
BINRARY_VERSION = "cpu"
2019-11-15 15:36:15 +08:00
PACKAGE_VERSION = VersionNumber([
2019-11-15 17:07:39 +08:00
versionNumberString : '${SEMVER}-cpu-${OS_NAME}-${CPU_ARCH}-${LOWER_BUILD_TYPE}-${BUILD_DATE_FORMATTED, "yyyyMMdd"}-${BUILDS_TODAY}'
2019-11-15 15:36:15 +08:00
]);
2019-11-15 17:07:39 +08:00
DOCKER_VERSION = "${SEMVER}-cpu-${OS_NAME}-${LOWER_BUILD_TYPE}"
}
stages {
2019-11-21 10:25:38 +08:00
stage("Run Build") {
2019-11-15 15:36:15 +08:00
agent {
kubernetes {
2019-11-21 15:42:10 +08:00
label "${env.BINRARY_VERSION}-build"
2019-11-15 15:36:15 +08:00
defaultContainer 'jnlp'
2019-11-15 17:07:39 +08:00
yamlFile 'ci/jenkins/pod/milvus-cpu-version-build-env-pod.yaml'
2019-11-15 15:36:15 +08:00
}
}
stages {
2019-11-21 10:25:38 +08:00
stage('Build') {
2019-11-15 15:36:15 +08:00
steps {
2019-11-21 15:42:10 +08:00
container("milvus-${env.BINRARY_VERSION}-build-env") {
2019-11-15 15:36:15 +08:00
script {
load "${env.WORKSPACE}/ci/jenkins/step/build.groovy"
}
}
}
}
2019-11-21 10:25:38 +08:00
stage('Code Coverage') {
2019-11-15 15:36:15 +08:00
steps {
2019-11-21 15:42:10 +08:00
container("milvus-${env.BINRARY_VERSION}-build-env") {
2019-11-15 15:36:15 +08:00
script {
load "${env.WORKSPACE}/ci/jenkins/step/coverage.groovy"
}
}
}
}
2019-11-21 10:25:38 +08:00
stage('Upload Package') {
2019-11-15 15:36:15 +08:00
steps {
2019-11-21 15:42:10 +08:00
container("milvus-${env.BINRARY_VERSION}-build-env") {
2019-11-15 15:36:15 +08:00
script {
load "${env.WORKSPACE}/ci/jenkins/step/package.groovy"
}
}
}
}
}
}
2019-11-21 10:25:38 +08:00
stage("Publish docker images") {
2019-11-15 15:36:15 +08:00
agent {
kubernetes {
2019-11-21 15:42:10 +08:00
label "${env.BINRARY_VERSION}-publish"
2019-11-15 15:36:15 +08:00
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/docker-pod.yaml'
}
}
stages {
2019-11-21 10:25:38 +08:00
stage('Publish') {
2019-11-15 15:36:15 +08:00
steps {
container('publish-images'){
script {
load "${env.WORKSPACE}/ci/jenkins/step/publishImages.groovy"
}
}
}
}
}
}
2019-11-21 10:25:38 +08:00
stage("Deploy to Development") {
2019-11-21 16:49:01 +08:00
environment {
2019-11-23 19:08:19 +08:00
FROMAT_SEMVER = "${env.SEMVER}".replaceAll("\\.", "-")
2019-11-23 14:53:30 +08:00
HELM_RELEASE_NAME = "${env.PIPELINE_NAME}-${env.FROMAT_SEMVER}-${env.BUILD_NUMBER}-single-${env.BINRARY_VERSION}".toLowerCase()
2019-11-21 16:49:01 +08:00
}
2019-11-15 15:36:15 +08:00
agent {
kubernetes {
2019-11-21 15:42:10 +08:00
label "${env.BINRARY_VERSION}-dev-test"
2019-11-15 15:36:15 +08:00
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/testEnvironment.yaml'
}
}
stages {
2019-11-21 10:25:38 +08:00
stage("Deploy to Dev") {
2019-11-15 15:36:15 +08:00
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/deploySingle2Dev.groovy"
}
}
}
}
2019-11-21 10:25:38 +08:00
stage("Dev Test") {
2019-11-15 15:36:15 +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-21 10:25:38 +08:00
stage ("Cleanup Dev") {
2019-11-15 15:36:15 +08:00
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/step/cleanupSingleDev.groovy"
}
}
}
}
}
2019-11-15 15:36:15 +08:00
post {
unsuccessful {
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
}