configure jenkinsfile
All checks were successful
Gitea/photolib/pipeline/head This commit looks good
All checks were successful
Gitea/photolib/pipeline/head This commit looks good
This commit is contained in:
parent
5633e782aa
commit
7cd996020c
68
Jenkinsfile
vendored
68
Jenkinsfile
vendored
@ -0,0 +1,68 @@
|
||||
def image_name = "dpedu/photolib"
|
||||
|
||||
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user