add jenkinsfile
Gitea/docker-plex/pipeline/head This commit looks good
Details
Gitea/docker-plex/pipeline/head This commit looks good
Details
This commit is contained in:
parent
14d9271a12
commit
a9cdc50b60
|
@ -0,0 +1,68 @@
|
||||||
|
def image_name = "dpedu/plex"
|
||||||
|
|
||||||
|
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