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'  
            }
              }
                 }
                    }
                       }
}
相关推荐
kaoa00017 小时前
Linux入门攻坚——62、memcached使用入门
linux·运维·memcached
model200518 小时前
alibaba linux3 系统盘清理
linux·运维·服务器
WG_1718 小时前
Linux:动态库加载总结_进程间通信+进程池 + 进程IPC(27/28/29/30/31/32)
linux·运维·服务器
一只懒鱼a19 小时前
docker部署nacos (版本2.3.2)
运维·docker
信创天地21 小时前
国产堡垒机部署实战:以奇安信、天融信为例构建运维安全三重防线
运维·安全
呉師傅1 天前
东芝3525AC彩色复印机CC219测试页打印方法【实际操作】
运维·网络·windows·计算机外设·电脑
宴之敖者、1 天前
Linux——权限
linux·运维·服务器
oscar9991 天前
构建敏捷团队的DevOps测试策略:速度与可靠性的平衡艺术
运维·测试·devops
卓码软件测评1 天前
软件信创测试和软件首版次认定机构【使用Postman的Pre-request Script动态处理数据】
测试工具·ci/cd·性能优化·单元测试·测试用例
星辰&与海1 天前
Proxmox导入虚拟机后进入dracut紧急模式
运维