增加生产pipeline
This commit is contained in:
parent
9f3c01d50c
commit
d42f970427
50
pipeline
Normal file
50
pipeline
Normal file
@ -0,0 +1,50 @@
|
||||
pipeline {
|
||||
|
||||
agent {
|
||||
label "dev"
|
||||
}
|
||||
|
||||
environment {
|
||||
BUILD_IMAGE = "${sh(script:'echo -n likei-dev:likei-h5-$(date +%Y%m%dv%H%M%S)', returnStdout: true)}"
|
||||
IMAGE_REP_TAG = "989328288674.dkr.ecr.ap-southeast-1.amazonaws.com/"
|
||||
K8S_NAMESPACE = "prod"
|
||||
K8S_DEPLOYMENT = "likei-h5"
|
||||
K8S_APP_LABEL = "likei-h5"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'export PATH=$HOME/bin:$PATH &&export NODE_HOME=/usr/local/node-v22.18.0 &&export PATH=$NODE_HOME/bin:$PATH &&export PATH=$PATH:/usr/local/go/bin &&npm install'
|
||||
sh 'export PATH=$HOME/bin:$PATH &&export NODE_HOME=/usr/local/node-v22.18.0 &&export PATH=$NODE_HOME/bin:$PATH &&export PATH=$PATH:/usr/local/go/bin &&npm run build:prod'
|
||||
sh 'du -sh dist'
|
||||
script {
|
||||
IMAGE_REP_TAG="${sh(script:'echo -n ${IMAGE_REP_TAG}${BUILD_IMAGE}', returnStdout: true)}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build image') {
|
||||
steps {
|
||||
sh "aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin 989328288674.dkr.ecr.ap-southeast-1.amazonaws.com"
|
||||
sh "docker build -t ${BUILD_IMAGE} ."
|
||||
}
|
||||
}
|
||||
stage('Upload image') {
|
||||
steps {
|
||||
sh "docker tag ${BUILD_IMAGE} ${IMAGE_REP_TAG}"
|
||||
sh "docker push ${IMAGE_REP_TAG}"
|
||||
sh "docker rmi -f ${BUILD_IMAGE} ${IMAGE_REP_TAG}"
|
||||
}
|
||||
}
|
||||
stage('Apply') {
|
||||
steps {
|
||||
sh "kubectl -n ${K8S_NAMESPACE} set image deployment/${K8S_DEPLOYMENT} ${K8S_APP_LABEL}=${IMAGE_REP_TAG} --kubeconfig ~/data/kube/prod-config"
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user