Jenkinsfile 6.7 KB
Newer Older
M
milvus-ci-robot 已提交
1
String cron_string = BRANCH_NAME == "master" ? "H 0 * * *" : ""
M
milvus-ci-robot 已提交
2 3
cron_string =  BRANCH_NAME == "0.5.1" ? "H 1 * * *" : cron_string

T
add ci  
test 已提交
4 5 6
pipeline {
    agent none

7 8
    triggers { cron(cron_string) }

T
add ci  
test 已提交
9 10 11 12 13 14 15
    options {
        timestamps()
    }

    parameters{
        choice choices: ['Release', 'Debug'], description: '', name: 'BUILD_TYPE'
        string defaultValue: 'cf1434e7-5a4b-4d25-82e8-88d667aef9e5', description: 'GIT CREDENTIALS ID', name: 'GIT_CREDENTIALS_ID', trim: true
M
milvus-ci-robot 已提交
16
        string defaultValue: 'registry.zilliz.com', description: 'DOCKER REGISTRY URL', name: 'DOKCER_REGISTRY_URL', trim: true
T
add ci  
test 已提交
17 18
        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
M
milvus-ci-robot 已提交
19
        string defaultValue: '1a527823-d2b7-44fd-834b-9844350baf14', description: 'JFROG CREDENTIALS ID', name: 'JFROG_CREDENTIALS_ID', trim: true
T
add ci  
test 已提交
20 21 22 23 24 25 26
    }

    environment {
        PROJECT_NAME = "milvus"
        LOWER_BUILD_TYPE = params.BUILD_TYPE.toLowerCase()
        SEMVER = "${BRANCH_NAME}"
        JOBNAMES = env.JOB_NAME.split('/')
27
        PIPELINE_NAME = "${JOBNAMES[0]}"
T
add ci  
test 已提交
28 29 30
    }

    stages {
T
test 已提交
31
        stage("Ubuntu 18.04") {
T
add ci  
test 已提交
32
            environment {
T
test 已提交
33
                OS_NAME = "ubuntu18.04"
T
add ci  
test 已提交
34
                PACKAGE_VERSION = VersionNumber([
35
                    versionNumberString : '${SEMVER}-${LOWER_BUILD_TYPE}-ubuntu18.04-x86_64-${BUILD_DATE_FORMATTED, "yyyyMMdd"}-${BUILDS_TODAY}'
T
add ci  
test 已提交
36 37 38 39 40 41 42 43 44 45
                ]);
                DOCKER_VERSION = "${SEMVER}-${OS_NAME}-${LOWER_BUILD_TYPE}"
            }

            stages {
                stage("Run Build") {
                    agent {
                        kubernetes {
                            label 'build'
                            defaultContainer 'jnlp'
T
test 已提交
46
                            yamlFile 'ci/jenkins/pod/milvus-build-env-pod.yaml'
T
add ci  
test 已提交
47 48 49 50 51 52 53 54
                        }
                    }

                    stages {
                        stage('Build') {
                            steps {
                                container('milvus-build-env') {
                                    script {
55
                                        load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/build.groovy"
56 57 58 59 60 61 62 63
                                    }
                                }
                            }
                        }
                        stage('Code Coverage') {
                            steps {
                                container('milvus-build-env') {
                                    script {
M
milvus-ci-robot 已提交
64
                                        load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/coverage.groovy"
T
add ci  
test 已提交
65 66 67 68 69 70 71 72
                                    }
                                }
                            }
                        }
                        stage('Upload Package') {
                            steps {
                                container('milvus-build-env') {
                                    script {
73
                                        load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/package.groovy"
T
add ci  
test 已提交
74 75 76 77 78 79 80 81 82 83 84 85
                                    }
                                }
                            }
                        }
                    }
                }

                stage("Publish docker images") {
                    agent {
                        kubernetes {
                            label 'publish'
                            defaultContainer 'jnlp'
T
test 已提交
86
                            yamlFile 'ci/jenkins/pod/docker-pod.yaml'
T
add ci  
test 已提交
87 88 89 90 91 92 93 94
                        }
                    }

                    stages {
                        stage('Publish') {
                            steps {
                                container('publish-images'){
                                    script {
95
                                        load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/publishImages.groovy"
T
add ci  
test 已提交
96 97 98 99 100 101 102 103 104 105 106 107
                                    }
                                }
                            }
                        }
                    }
                }

                stage("Deploy to Development") {
                    agent {
                        kubernetes {
                            label 'dev-test'
                            defaultContainer 'jnlp'
T
test 已提交
108
                            yamlFile 'ci/jenkins/pod/testEnvironment.yaml'
T
add ci  
test 已提交
109 110 111 112 113 114 115 116
                        }
                    }

                    stages {
                        stage("Deploy to Dev") {
                            steps {
                                container('milvus-test-env') {
                                    script {
117
                                        load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/deploySingle2Dev.groovy"
T
add ci  
test 已提交
118 119 120 121 122 123 124 125 126
                                    }
                                }
                            }
                        }

                        stage("Dev Test") {
                            steps {
                                container('milvus-test-env') {
                                    script {
127 128
                                        boolean isNightlyTest = isTimeTriggeredBuild()
                                        if (isNightlyTest) {
129
                                            load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/singleDevNightlyTest.groovy"
M
milvus-ci-robot 已提交
130
                                        } else {
131 132
                                            load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/singleDevTest.groovy"
                                        }
T
add ci  
test 已提交
133 134 135 136 137 138 139 140 141
                                    }
                                }
                            }
                        }

                        stage ("Cleanup Dev") {
                            steps {
                                container('milvus-test-env') {
                                    script {
142
                                        load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/cleanupSingleDev.groovy"
T
add ci  
test 已提交
143 144 145 146 147 148 149 150 151
                                    }
                                }
                            }
                        }
                    }
                    post {
                        unsuccessful {
                            container('milvus-test-env') {
                                script {
152
                                    load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/cleanupSingleDev.groovy"
T
add ci  
test 已提交
153 154 155 156 157 158 159 160 161 162
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

163
boolean isTimeTriggeredBuild() {
164 165
    if (currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').size() != 0) {
        return true
166 167 168
    }
    return false
}