2023-03-22 12:57:54
22 03 2023
摘要:k8s 流水线jenkins文件

1、jenkins的流水线配置文件myjenkins
pipeline { agent { node { label 'base' } } stages { stage('拉取代码') { agent none steps { container('base') { git(url: 'git@17.19.10.17:/gitdata', credentialsId: 'rsdlb171', branch: 'master', changelog: true, poll: false) } } } stage('生成镜像') { agent none steps { container('base') { sh "docker build -t $APP_NAME:latest -f DLBRealityCenterSystem/Dockerfile ./ " } } } stage('镜像推送到hub') { agent none steps { container('base') { withCredentials([usernamePassword(credentialsId : 'harbor-account' ,passwordVariable : 'password' ,usernameVariable : 'username' ,)]) { sh 'docker login $REGISTRY -u "$username" -p "$password"' sh "docker tag $APP_NAME:latest $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:v$BUILD_NUMBER " sh "docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:v$BUILD_NUMBER " } } } } stage('部署到线上') { agent none steps { container('base') { input(message: '确定部署到开发?', submitter: '') withCredentials([kubeconfigContent(credentialsId : 'dev-kubeconfig' ,variable : 'KUBECONFIG_CONFIG' ,)]) { sh 'mkdir -p ~/.kube/' sh 'echo "$KUBECONFIG_CONFIG" > ~/.kube/config' sh 'envsubst < DLBRealityCenterSystem/ps-system.yaml | kubectl apply -f -' } } } } } environment { DOCKER_CREDENTIAL_ID = 'dockerhub-id' GITHUB_CREDENTIAL_ID = 'github-id' KUBECONFIG_CREDENTIAL_ID = 'dev-kubeconfig' REGISTRY = '17.19.10.17:30002' DOCKERHUB_NAMESPACE = 'library' GITHUB_ACCOUNT = 'kubesphere' APP_NAME = 'pssystem' } parameters { string(name: 'TAG_NAME', defaultValue: '', description: '') } }

延伸阅读
  1. 上一篇:JDK
  2. 下一篇:Nginx
发表评论