69 lines
1.8 KiB
Plaintext
69 lines
1.8 KiB
Plaintext
|
def image_name = "dpedu/desktop"
|
||
|
|
||
|
pipeline {
|
||
|
agent {
|
||
|
kubernetes {
|
||
|
yaml """
|
||
|
apiVersion: v1
|
||
|
kind: Pod
|
||
|
spec:
|
||
|
podAntiAffinity:
|
||
|
preferredDuringSchedulingIgnoredDuringExecution: # avoid nodes already running a jenkins job
|
||
|
- podAffinityTerm:
|
||
|
labelSelector:
|
||
|
matchExpressions:
|
||
|
- key: jenkins
|
||
|
operator: In
|
||
|
values:
|
||
|
- slave
|
||
|
topologyKey: node
|
||
|
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("ubuntu:focal").pull()
|
||
|
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")
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
stage("Show images") {
|
||
|
steps {
|
||
|
container("docker") {
|
||
|
sh 'docker images'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|