简单版解决方法:
在jenkins容器里执行git config —global http.sslVerify false
或者将此文件挂载进去
然而跑一个示例的流水线依然报该错误。原来jenkins调取的slave流水线里没有Git忽略ssl配置
通过如下命令查看jenkins/inbound-agent镜像的家目录:
docker history --format {{.CreatedBy}} --no-trunc=true jenkins/inbound-agent:4.11-1-jdk11 |sed "s?/bin/sh\ -c\ \#(nop)\ ??g"|sed "s?/bin/sh\ -c?RUN?g" | tac

所以将示例的流水线加上该挂载就能跑成功了(mountPath)
def label = "slave-${UUID.randomUUID().toString()}"podTemplate(label: label, containers: [containerTemplate(name: 'golang', image: 'golang:1.16.14-alpine3.14', command: 'cat', ttyEnabled: true),containerTemplate(name: 'docker', image: 'docker:latest', command: 'cat', ttyEnabled: true),containerTemplate(name: 'kubectl', image: 'cnych/kubectl', command: 'cat', ttyEnabled: true)], serviceAccount: 'jenkins', volumes: [hostPathVolume(mountPath: '/home/jenkins/.kube', hostPath: '/root/.kube'),hostPathVolume(mountPath: '/home/jenkins/.gitconfig', hostPath: '/root/.gitconfig'),hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')]) {node(label) {def myRepo = checkout scmdef gitCommit = myRepo.GIT_COMMITdef gitBranch = myRepo.GIT_BRANCHstage('单元测试') {echo "测试阶段"}stage('代码编译打包') {container('golang') {echo "代码编译打包阶段"}}stage('构建 Docker 镜像') {container('docker') {echo "构建 Docker 镜像阶段"}}stage('运行 Kubectl') {container('kubectl') {echo "查看 K8S 集群 Pod 列表"sh "kubectl get pods"}}}}

