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'  
            }
              }
                 }
                    }
                       }
}
相关推荐
碳基沙盒21 小时前
OpenClaw 多 Agent 配置实战指南
运维
蝎子莱莱爱打怪4 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
DianSan_ERP4 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
呉師傅5 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
不是二师兄的八戒5 天前
Linux服务器挂载OSS存储的完整实践指南
linux·运维·服务器
zhangfeng11335 天前
趋动云 如何ssh登录 服务区 项目server
运维·人工智能·ssh
ZeroNews内网穿透5 天前
谷歌封杀OpenClaw背后:本地部署或是出路
运维·服务器·数据库·安全
失重外太空啦5 天前
nginx
运维·nginx
Gofarlic_oms15 天前
避免Kisssoft高级分析模块过度采购的科学评估方法
大数据·linux·运维·人工智能·matlab
田井中律.5 天前
服务器部署问题汇总(ubuntu24.04.3)
运维·服务器