资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Jenkins在Kubernetes中构建Docker镜像并推送至Registry

def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, cloud: 'kubernetes', 
    containers: [
        containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
        containerTemplate(name: 'docker', image: 'docker:stable', ttyEnabled: true, command: 'cat')
    ],
    volumes: [
            hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock'),
            // persistentVolumeClaim(clainName: 'jenkins-slave-gfs', mountPAth: '/home/jenkins', readOnly: false)
        ],
    ) {

    node(label) {
        def registryAddr = 'registry.k8s.io'
        stage('build image') {
            checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[cancelProcessOnExternalsFail: true, credentialsId: '7dd36403-f190-48bf-ac43-e082f6b37709', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: 'https://192.168.0.252:8443/svn/k8s/dev/dysjds']], quietOperation: true, workspaceUpdater: [$class: 'UpdateUpdater']])
            container('docker') {
                        sh "docker build -t ${registryAddr}/k8sdysjds:1 ."
                }
            container('docker') {
                        sh "docker push ${registryAddr}/k8sdysjds:1 "
                }            
        }
    }
}

文章标题:Jenkins在Kubernetes中构建Docker镜像并推送至Registry
本文URL:http://cdkjz.cn/article/gihpeo.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220