jenkins部署镜像到k8s遇到的问题
使用k8s插件Kubernetes Continuous Deployhttps://plugins.jenkins.io/kubernetes-cd/#documentationpipeline添加kubernetesDeploy(enableConfigSubstitution: false, kubeconfigId: ‘kubeconfig’, configs: ‘deploy/*.yam
·
使用k8s插件Kubernetes Continuous Deploy
- https://plugins.jenkins.io/kubernetes-cd/#documentation
- pipeline添加kubernetesDeploy(enableConfigSubstitution: false, kubeconfigId: ‘kubeconfig’, configs: ‘deploy/*.yaml’)
pipeline {
agent { label "baseline-front" }
environment {
GITLAB_ID = '8cb89727-c404-44e1-b3d7-e82dde2df432'
GITLAB_URL = 'http://xxx.xxx.xxx/devops1/baseline_front.git'
REGISTRY = 'https://core.harbor.haier'
DOCKERHUB_NAMESPACE = 'core.harbor.haier/baseline'
APP_NAME = 'baseline_frontend'
VERSION = 'latest'
BRANCH_NAME = 'dev'
}
stages {
stage('拉取代码') {
steps {
echo '**************拉取代码****************'
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: "$GITLAB_ID", url: "$GITLAB_URL"]]])
}
}
stage('编译构建') {
steps {
container('front') {
script {
echo '***************编译构建****************'
sh 'npm ci'
sh 'CI=false npm run build'
}
}
}
}
stage('构建Docker镜像') {
steps {
container('front') {
script {
echo '*************构建Docker镜像**************'
sh 'docker login -u admin -p Harbor12345 $REGISTRY'
sh 'docker build -f deploy/Dockerfile -t $APP_NAME:$VERSION .'
sh 'docker tag $APP_NAME:$VERSION $DOCKERHUB_NAMESPACE/$APP_NAME:$VERSION'
sh 'docker push $DOCKERHUB_NAMESPACE/$APP_NAME:$VERSION'
}
}
}
}
stage('部署') {
steps {
echo '*************部署***************'
kubernetesDeploy(enableConfigSubstitution: false, kubeconfigId: 'deploy_k8s', configs: 'deploy/*.yaml')
}
}
}
}
更多推荐
已为社区贡献2条内容
所有评论(0)