forked from Thirdparty/wvp
1
0
Fork 0
wvp/builds/Jenkinsfile-roadbed

44 lines
1.6 KiB
Plaintext

pipeline {
agent any
environment {
REGISTRY='registry.cn-chengdu.aliyuncs.com'
INTERIOR_REGISTRY='registry-vpc.cn-chengdu.aliyuncs.com'
IMAGE_NAMESPACE='chkj'
IMAGE_NAME='roadbed-iot-vmp-vmanager'
DOCKER_FILE="builds/Dockerfile-roadbed"
K8S_FILE="builds/deploy-roadbed.yml"
}
stages {
stage('compile & buildImage->push') {
steps {
withMaven(maven: 'M3', jdk: '8') {
sh 'mvn clean package -Dmaven.test.skip=true'
}
withDockerServer([credentialsId: 'chkj-docker-client-cert', uri: 'tcp://8.137.98.119']) {
withCredentials([usernamePassword(credentialsId: 'ch-aliyun-registry', passwordVariable: 'DOCKER_PASSWORD', usernameVariable: 'DOCKER_USERNAME')]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $INTERIOR_REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker build -f $DOCKER_FILE -t $INTERIOR_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$BUILD_ID .'
sh 'echo "push start..."'
sh 'docker push $INTERIOR_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$BUILD_ID'
}
}
}
}
stage('ack deploy') {
agent none
steps {
configFileProvider([configFile(fileId: '87b5c827-bd51-40af-99f4-31a800614e92', targetLocation: 'K8S-CONFIG', variable: 'KUBECONFIG')]) {
sh 'export tag=$BUILD_ID && envsubst < $K8S_FILE | kubectl apply -f -'
}
}
}
}
}