def image_name = "dpedu/s3www" pipeline { agent { kubernetes { // inheritFrom 'mypod' yaml """ apiVersion: v1 kind: Pod spec: containers: - name: docker image: docker:20-dind args: - "--insecure-registry" - "dockermirror:5000" securityContext: privileged: true """ } } stages { stage("Build image") { steps { container("docker") { script { try { docker.withRegistry('http://dockermirror:5000') { docker.image(image_name).pull() // Pull a recent version to share base layers with (?) } } catch (exc) { echo "couldn't pull image, assuming we're building it for the first time" } docker.build(image_name) } } } } stage("Push image") { steps { container("docker") { script { docker.withRegistry('http://dockermirror:5000') { docker.image(image_name).push("latest") } } } } } } }