jenkins-ci/cd yaml模版配置

yaml 复制代码
apiVersion: v1
kind: Pod
spec:
  volumes:
  - name: certs-ca
    emptyDir: {}
  - name: certs-client
    emptyDir: {}
  containers:
  - name: dind
    image: docker:24.0-dind
    securityContext:
      privileged: true
    env:
    - name: DOCKER_TLS_CERTDIR
      value: /certs
    volumeMounts:
    - name: certs-ca
      mountPath: /certs/ca
    - name: certs-client
      mountPath: /certs/client
    tty: true
  - name: docker
    image: docker:24.0
    command:
    - cat
    tty: true
    env:
    - name: DOCKER_TLS_CERTDIR
      value: /certs
    - name: DOCKER_HOST
      value: tcp://localhost:2376
    - name: DOCKER_TLS_VERIFY
      value: "1"
    - name: DOCKER_CERT_PATH
      value: /certs/client
    volumeMounts:
    - name: certs-client
      mountPath: /certs/client
      readOnly: true
  - name: kubectl
    image: alpine/kubectl:1.34.2
    command:
    - cat
    tty: true
最后pipeline
js 复制代码
pipeline {
     environment {
    image ="hub.da9893.com/k8s/$JOB_NAME:$BUILD_ID"
        }   
    agent { 
     kubernetes {
       inheritFrom 'docker'
     	 }
   			 }   
   			 
    stages {
      stage('Get Code') {
        steps {  
checkout scmGit(branches: [[name: '*/v10.1.3']], extensions: [], userRemoteConfigs: [[credentialsId: 'ltd', url: 'http://WW.GITHUB/robot-weit']])         }
           }
           
stage('Docker Build Push') {
    steps {
        container('docker') { 
            sh 'docker info'  
            sh 'ps aux | grep docker' 
            //script {
              //  withDockerRegistry(credentialsId: 'hub', url: 'https://hub.da9893.com') {
                //    def builtImage = docker.build("${image}", ".")
                  //  builtImage.push()
                //}
                //sh "docker rmi ${image} || true"
           // }
        }
    }
}
    stage('Deloy SIT') {
    steps {
        container('kubectl') { 
            withKubeConfig(credentialsId: '16-k8s', serverUrl: 'https://192.168.12.16:6443') {
            sh 'kubectl get pods -A'  
            }
              }
                 }
                    }
                       }
}
相关推荐
斯普信云原生组2 小时前
开源软件日志统一管理方案-Filebeat
运维·jenkins
飞Link2 小时前
【Anaconda】Linux(CentOS7)下安装Anaconda教程
linux·运维·python
Ama_tor2 小时前
docker|F盘安装の1键部署软件及数据储存+2个保姆级运行实例
运维·docker·容器
@时间旅行者@2 小时前
LINUX离线安装postgres,rpm方式安装
linux·运维·服务器·postgresql·离线安装
whlqjn_12112 小时前
Ubuntu 20.04图形界面卸载
linux·运维·ubuntu
杨云龙UP2 小时前
SQL Server 2016通过SSMS(SQL Server Management Studio)图形界面完成创建用户和授权_20251230
运维·服务器·数据库
斯普信云原生组3 小时前
Linux 平台 Redis Insight 安装卸载与常见问题
linux·运维·redis
qq_416276423 小时前
linux bashrc写各种离线库路径并验证
linux·运维·服务器
航Hang*3 小时前
第二章:网络系统建设与运维(中级)——华为设备基本命令
运维·计算机网络·华为·ensp·交换机