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'  
            }
              }
                 }
                    }
                       }
}
相关推荐
阿杰技术7 分钟前
SillyTavern(酒馆)AI聊天:本地与云服务器部署全攻略
运维·服务器
网络与设备以及操作系统学习使用者13 分钟前
vi与vim在openEuler中的差异及应用
linux·运维·网络·学习·vim
ylscode30 分钟前
巨齿鲨突袭GitHub:5500余仓库沦陷,开源供应链安全防线再遭重创
运维·服务器·网络·安全·安全威胁分析
shy_snow38 分钟前
Nginx解决跨域问题
运维·nginx
c++逐梦人39 分钟前
epoll ET服务器(Reactor模式)
运维·服务器·php
牛奔1 小时前
codebuddy 桌面版 如何配置自己的模型
运维·服务器·开发语言·php
SilentSamsara1 小时前
日志与可观测性:logging 进阶配置与结构化日志实战
运维·开发语言·python·青少年编程
学困昇2 小时前
Linux IPC 详解:匿名管道、命名管道、共享内存与信号量
linux·运维·服务器·c语言·c++·人工智能
TYKJ0232 小时前
服务器带宽的"独享"和"共享"到底差在哪?从原理到实测讲清楚
运维·服务器·后端
JustNow_Man2 小时前
视频深度解析:CI/CD 已死,智能体时代需要持续计算
ci/cd