docker-s3www/Jenkinsfile

52 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2022-04-21 21:48:24 -07:00
def image_name = "dpedu/s3www"
2022-04-21 21:20:54 -07:00
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 {
2022-04-21 21:48:24 -07:00
stage("Build image") {
2022-04-21 21:20:54 -07:00
steps {
container("docker") {
script {
try {
2022-04-21 21:48:24 -07:00
docker.withRegistry('http://dockermirror:5000') {
docker.image(image_name).pull() // Pull a recent version to share base layers with (?)
}
2022-04-21 21:20:54 -07:00
} catch (exc) {
echo "couldn't pull image, assuming we're building it for the first time"
}
2022-04-21 21:48:24 -07:00
docker.build(image_name)
}
}
}
}
stage("Push image") {
steps {
container("docker") {
script {
docker.withRegistry('http://dockermirror:5000') {
docker.image(image_name).push("latest")
}
2022-04-21 21:20:54 -07:00
}
}
}
}
}
}