2022-08-01 10:26:38 +08:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent {
|
|
|
|
kubernetes {
|
|
|
|
defaultContainer 'main'
|
|
|
|
yamlFile "ci/jenkins/pod/rte.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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
timestamps()
|
2024-01-05 17:20:47 +08:00
|
|
|
timeout(time: 200, unit: 'MINUTES')
|
2022-08-01 10:26:38 +08:00
|
|
|
// parallelsAlwaysFailFast()
|
2022-11-04 19:17:40 +08:00
|
|
|
disableConcurrentBuilds()
|
2022-08-01 10:26:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
DOCKER_CREDENTIALS_ID = "dockerhub"
|
|
|
|
TARGET_REPO = "milvusdb"
|
|
|
|
CI_DOCKER_CREDENTIAL_ID = "harbor-milvus-io-registry"
|
|
|
|
HARBOR_REPO = "harbor.milvus.io"
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2023-10-24 09:30:10 +08:00
|
|
|
stage('Generate Image Tag') {
|
2023-08-22 10:44:21 +08:00
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
def date = sh(returnStdout: true, script: 'date +%Y%m%d').trim()
|
|
|
|
def gitShortCommit = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
|
|
|
|
def imageTag = "${env.BRANCH_NAME}-${date}-${gitShortCommit}"
|
|
|
|
sh "echo ${imageTag} > imageTag.txt"
|
|
|
|
stash includes: 'imageTag.txt', name: 'imageTag'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 19:10:28 +08:00
|
|
|
stage('Build & Publish Milvus Images'){
|
2022-08-01 10:26:38 +08:00
|
|
|
parallel {
|
2023-08-22 10:44:21 +08:00
|
|
|
stage('Build Milvus Images on amd') {
|
2022-08-01 10:26:38 +08:00
|
|
|
steps {
|
|
|
|
container('main') {
|
|
|
|
script {
|
2024-02-01 11:49:03 +08:00
|
|
|
|
2023-08-29 19:10:28 +08:00
|
|
|
sh './build/set_docker_mirror.sh'
|
2024-02-01 11:49:03 +08:00
|
|
|
sh """
|
2024-02-19 15:16:55 +08:00
|
|
|
# disable dirty tag
|
|
|
|
sed -i. 's/--dirty="-dev"//g' Makefile
|
2024-02-01 11:49:03 +08:00
|
|
|
export IS_NETWORK_MODE_HOST="true"
|
|
|
|
build/builder.sh /bin/bash -c \"make install\"
|
|
|
|
"""
|
2023-08-29 19:10:28 +08:00
|
|
|
|
2023-08-22 10:44:21 +08:00
|
|
|
dir ("imageTag"){
|
|
|
|
try{
|
|
|
|
unstash 'imageTag'
|
|
|
|
imageTag=sh(returnStdout: true, script: 'cat imageTag.txt | tr -d \'\n\r\'')
|
|
|
|
}catch(e){
|
|
|
|
print "No Image Tag info remained ,please rerun build to build new image."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 19:10:28 +08:00
|
|
|
withCredentials([usernamePassword(credentialsId: "${env.DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]){
|
|
|
|
sh "docker login -u '${DOCKER_USERNAME}' -p '${DOCKER_PASSWORD}'"
|
|
|
|
sh """
|
|
|
|
export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus"
|
|
|
|
export MILVUS_HARBOR_IMAGE_REPO="${env.HARBOR_REPO}/milvus/milvus"
|
|
|
|
export MILVUS_IMAGE_TAG="${imageTag}-amd64"
|
|
|
|
build/build_image.sh
|
|
|
|
docker push \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
docker logout
|
|
|
|
"""
|
|
|
|
}
|
2022-08-01 10:26:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
withCredentials([usernamePassword(credentialsId: "${env.CI_DOCKER_CREDENTIAL_ID}", usernameVariable: 'CI_REGISTRY_USERNAME', passwordVariable: 'CI_REGISTRY_PASSWORD')]){
|
|
|
|
sh "docker login ${env.HARBOR_REPO} -u '${CI_REGISTRY_USERNAME}' -p '${CI_REGISTRY_PASSWORD}'"
|
|
|
|
sh """
|
2023-08-22 10:44:21 +08:00
|
|
|
export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus"
|
2022-08-01 10:26:38 +08:00
|
|
|
export MILVUS_HARBOR_IMAGE_REPO="${env.HARBOR_REPO}/milvus/milvus"
|
2023-08-22 10:44:21 +08:00
|
|
|
export MILVUS_IMAGE_TAG="${imageTag}-amd64"
|
|
|
|
docker tag \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
2022-08-01 10:26:38 +08:00
|
|
|
docker push \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
docker logout
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-22 10:44:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
stage('Build Milvus Images on arm') {
|
2022-08-01 10:26:38 +08:00
|
|
|
agent {
|
2023-08-22 10:44:21 +08:00
|
|
|
label 'arm'
|
2022-08-01 10:26:38 +08:00
|
|
|
}
|
|
|
|
steps {
|
2023-08-22 10:44:21 +08:00
|
|
|
script {
|
|
|
|
sh """
|
|
|
|
cp -r /tmp/krte/cache/.docker .
|
2023-08-29 19:10:28 +08:00
|
|
|
PLATFORM_ARCH="arm64" build/builder.sh /bin/bash -c "make install"
|
2023-08-22 10:44:21 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
dir ("imageTag"){
|
|
|
|
try{
|
|
|
|
unstash 'imageTag'
|
|
|
|
imageTag=sh(returnStdout: true, script: 'cat imageTag.txt | tr -d \'\n\r\'')
|
|
|
|
}catch(e){
|
|
|
|
print "No Image Tag info remained ,please rerun build to build new image."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 19:10:28 +08:00
|
|
|
withCredentials([usernamePassword(credentialsId: "${env.DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]){
|
|
|
|
sh "docker login -u '${DOCKER_USERNAME}' -p '${DOCKER_PASSWORD}'"
|
|
|
|
sh """
|
|
|
|
export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus"
|
|
|
|
export MILVUS_HARBOR_IMAGE_REPO="${env.HARBOR_REPO}/milvus/milvus"
|
|
|
|
export MILVUS_IMAGE_TAG="${imageTag}-arm64"
|
|
|
|
BUILD_ARGS="--build-arg TARGETARCH=arm64" build/build_image.sh
|
|
|
|
docker push \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
docker logout
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:44:21 +08:00
|
|
|
|
|
|
|
withCredentials([usernamePassword(credentialsId: "${env.CI_DOCKER_CREDENTIAL_ID}", usernameVariable: 'CI_REGISTRY_USERNAME', passwordVariable: 'CI_REGISTRY_PASSWORD')]){
|
|
|
|
sh "docker login ${env.HARBOR_REPO} -u '${CI_REGISTRY_USERNAME}' -p '${CI_REGISTRY_PASSWORD}'"
|
|
|
|
sh """
|
|
|
|
export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus"
|
|
|
|
export MILVUS_HARBOR_IMAGE_REPO="${env.HARBOR_REPO}/milvus/milvus"
|
|
|
|
export MILVUS_IMAGE_TAG="${imageTag}-arm64"
|
|
|
|
docker tag \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
docker push \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
docker logout
|
|
|
|
docker rmi \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} -f
|
2023-08-29 19:10:28 +08:00
|
|
|
docker rmi \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} -f
|
2023-08-22 10:44:21 +08:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
2022-08-01 10:26:38 +08:00
|
|
|
script {
|
2023-08-29 19:10:28 +08:00
|
|
|
// if (currentBuild.currentResult == "SUCCESS") {
|
|
|
|
// sh "cp -r .docker /tmp/krte/cache/"
|
|
|
|
// }
|
2023-08-22 10:44:21 +08:00
|
|
|
sh """
|
|
|
|
pwd
|
|
|
|
sudo rm -rf .env .docker
|
|
|
|
sudo rm -rf *
|
|
|
|
"""
|
2022-08-01 10:26:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:44:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage ('publish multi-platform image') {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
dir ("imageTag"){
|
|
|
|
try{
|
|
|
|
unstash 'imageTag'
|
|
|
|
imageTag=sh(returnStdout: true, script: 'cat imageTag.txt | tr -d \'\n\r\'')
|
|
|
|
}catch(e){
|
|
|
|
print "No Image Tag info remained ,please rerun build to build new image."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
withCredentials([usernamePassword(credentialsId: "${env.DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
|
|
|
|
sh 'docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}'
|
|
|
|
sh """
|
|
|
|
export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus"
|
|
|
|
export MILVUS_HARBOR_IMAGE_REPO="${env.HARBOR_REPO}/milvus/milvus"
|
|
|
|
|
|
|
|
export ARM_MILVUS_IMAGE_TAG="${imageTag}-arm64"
|
|
|
|
export AMD_MILVUS_IMAGE_TAG="${imageTag}-amd64"
|
|
|
|
export MILVUS_IMAGE_TAG="${imageTag}"
|
|
|
|
|
|
|
|
docker pull \${MILVUS_HARBOR_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG}
|
|
|
|
docker tag \${MILVUS_HARBOR_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG}
|
|
|
|
|
2022-08-01 10:26:38 +08:00
|
|
|
|
2023-08-22 10:44:21 +08:00
|
|
|
docker manifest create \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:\${AMD_MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG}
|
|
|
|
docker manifest annotate \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:\${AMD_MILVUS_IMAGE_TAG} --os linux --arch amd64
|
|
|
|
docker manifest annotate \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG} --os linux --arch arm64
|
|
|
|
docker manifest push \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
|
|
|
|
docker manifest create \${MILVUS_IMAGE_REPO}:${env.BRANCH_NAME}-latest \${MILVUS_IMAGE_REPO}:\${AMD_MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG}
|
|
|
|
docker manifest annotate \${MILVUS_IMAGE_REPO}:${env.BRANCH_NAME}-latest \${MILVUS_IMAGE_REPO}:\${AMD_MILVUS_IMAGE_TAG} --os linux --arch amd64
|
|
|
|
docker manifest annotate \${MILVUS_IMAGE_REPO}:${env.BRANCH_NAME}-latest \${MILVUS_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG} --os linux --arch arm64
|
|
|
|
docker manifest push \${MILVUS_IMAGE_REPO}:${env.BRANCH_NAME}-latest
|
|
|
|
|
|
|
|
docker logout
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
withCredentials([usernamePassword(credentialsId: "${env.CI_DOCKER_CREDENTIAL_ID}", usernameVariable: 'CI_REGISTRY_USERNAME', passwordVariable: 'CI_REGISTRY_PASSWORD')]){
|
|
|
|
sh """
|
|
|
|
docker login ${env.HARBOR_REPO} -u '${CI_REGISTRY_USERNAME}' -p '${CI_REGISTRY_PASSWORD}'
|
|
|
|
|
|
|
|
export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus"
|
|
|
|
export MILVUS_HARBOR_IMAGE_REPO="${env.HARBOR_REPO}/milvus/milvus"
|
|
|
|
|
|
|
|
export ARM_MILVUS_IMAGE_TAG="${imageTag}-arm64"
|
|
|
|
export AMD_MILVUS_IMAGE_TAG="${imageTag}-amd64"
|
|
|
|
export MILVUS_IMAGE_TAG="${imageTag}"
|
|
|
|
|
|
|
|
|
|
|
|
docker manifest create \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_HARBOR_IMAGE_REPO}:\${AMD_MILVUS_IMAGE_TAG} \${MILVUS_HARBOR_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG}
|
|
|
|
docker manifest annotate \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_HARBOR_IMAGE_REPO}:\${AMD_MILVUS_IMAGE_TAG} --os linux --arch amd64
|
|
|
|
docker manifest annotate \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_HARBOR_IMAGE_REPO}:\${ARM_MILVUS_IMAGE_TAG} --os linux --arch arm64
|
|
|
|
|
|
|
|
docker manifest push \${MILVUS_HARBOR_IMAGE_REPO}:\${MILVUS_IMAGE_TAG}
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-08-01 10:26:38 +08:00
|
|
|
}
|
|
|
|
}
|
2023-08-22 10:44:21 +08:00
|
|
|
|
2022-08-01 10:26:38 +08:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
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},qa@zilliz.com,devops@zilliz.com"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cleanup {
|
|
|
|
container('main') {
|
|
|
|
script {
|
|
|
|
sh 'find . -name . -o -prune -exec rm -rf -- {} +' /* clean up our workspace */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|