k8s-jenkins 自动化1

一个流水线例子:

设置参数化构建:

流水线指令:

def label = "docker-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
apiVersion: v1
kind: Pod
metadata:
  name: docker-default
  namespace: kube-ops 
spec:
  hostNetwork: true
  containers:
  - name: docker
    image: ${imageSlave}
    command: ['cat']
    tty: true
    volumeMounts:
    - name: dockersock
      mountPath: /var/run/docker.sock
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock
"""
  ) {

  node(label) {
    stage('Build Docker image') {
      container('docker') {
        sh "docker login --username ${regUser} --password ${regPasswd} ${regUrl}"
        sh "docker images"
      }
    }
  }
}

  

 

posted @ 2019-04-01 09:48  划得戳  阅读(170)  评论(0编辑  收藏  举报