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'  
            }
              }
                 }
                    }
                       }
}
相关推荐
CHINA红旗下几秒前
固定虚拟机的IP地址
运维·服务器·网络
DO_Community2 分钟前
百亿参数开源模型托管成本账:从按 Token 计费到单卡 GPU 服务器怎么选?
运维·服务器·开源·llm·agent
着迷不白5 分钟前
十、网络客户端工具curl, wget, ssh, scp, sftp, rsync
运维·网络·ssh
the sun348 分钟前
集群架构实操:MySQL主、从节点配置
运维·服务器
睡不醒男孩03082319 分钟前
CLup篇之数据库传统运维对比
运维·数据库
changxiang27 分钟前
Jenkins备忘
运维·jenkins
biter down34 分钟前
4:Ubuntu 22.04 安装完成后的收尾与优化
linux·运维·ubuntu
热爱运维的小七39 分钟前
深度解析|应用性能 + RUM + 拨测:现代 IT 运维的可观测性“铁三角”
运维·it运维·devops·apm·rum·网站拨测
zhuhai_xigedian40 分钟前
物联网技术在源网荷储系统中的创新应用
大数据·运维·人工智能·区块链·能源
xsc-xyc43 分钟前
CasaOS + Docker 挂载外接硬盘部署 Jellyfin 私人影院
运维·docker·容器