我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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
转载注明:http://shouzuofang.com/article/gihpeo.html

其他资讯