Add Jenkins pipeline to build and push container
This commit is contained in:
52
Jenkinsfile
vendored
Normal file
52
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
REGISTRY_HOST = 'gitea.mindboost.team'
|
||||
IMAGE_NAME = 'interkollektives/lichterei-web'
|
||||
IMAGE_TAG = '0.0.1'
|
||||
IMAGE_REF = "${REGISTRY_HOST}/${IMAGE_NAME}:${IMAGE_TAG}"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build image') {
|
||||
steps {
|
||||
sh """
|
||||
docker build \
|
||||
--file kirby/Dockerfile \
|
||||
--tag ${IMAGE_REF} \
|
||||
kirby
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push image') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'gitea-container-registry',
|
||||
usernameVariable: 'REGISTRY_USER',
|
||||
passwordVariable: 'REGISTRY_PASSWORD'
|
||||
)]) {
|
||||
sh """
|
||||
echo "${REGISTRY_PASSWORD}" | docker login ${REGISTRY_HOST} \
|
||||
--username "${REGISTRY_USER}" --password-stdin
|
||||
docker push ${IMAGE_REF}
|
||||
docker logout ${REGISTRY_HOST}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'docker image prune --force'
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user