pixelfed-container/Jenkinsfile

74 lines
2.4 KiB
Plaintext
Raw Normal View History

2020-05-28 18:19:38 +02:00
project = "pixelfed"
repo = "zknt"
registry = "reg.zknt.org"
registry_credentials = "6ff44976-23cd-4cc2-902c-de8c340e65e5"
timeStamp = Calendar.getInstance().getTime().format('YYYY-MM-dd',TimeZone.getTimeZone('UTC'))
2020-06-22 14:10:13 +02:00
official_image = ""
2020-05-28 18:19:38 +02:00
pipeline {
agent any
triggers {
2020-06-23 14:00:12 +02:00
upstream(upstreamProjects: "../debian-php/trunk", threshold: hudson.model.Result.SUCCESS)
2020-05-28 18:19:38 +02:00
}
stages {
stage('Build image') {
steps {
withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) {
script {
def customImage = docker.build(registry+'/'+repo+'/'+project, "--build-arg DATE=$timeStamp --pull .")
2020-05-28 18:21:23 +02:00
customImage.push(timeStamp)
2020-05-28 18:19:38 +02:00
customImage.push()
2020-06-22 14:10:13 +02:00
io_registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7"
withDockerRegistry([ credentialsId: io_registry_credentials ]) {
official_image = repo+'/'+project
2020-05-28 18:19:38 +02:00
sh "docker image tag " + registry+'/'+repo+'/'+project + ' ' + official_image
2020-05-28 18:21:23 +02:00
sh "docker image tag " + registry+'/'+repo+'/'+project + ' ' + official_image+':'+timeStamp
2020-05-28 18:19:38 +02:00
sh "docker push " + official_image
2020-05-28 18:21:23 +02:00
sh "docker push " + official_image+':'+timeStamp
2020-05-28 18:19:38 +02:00
}
}
}
}
}
}
post {
always{
emailext body: 'build finished', subject: '[jenkins] docker ' + project + ': ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true
}
2020-06-22 14:10:13 +02:00
success {
withCredentials([string(credentialsId: '90700f9c-c5cf-449b-81af-d854c08265f5', variable: 'CONFIG_JSON')]) {
withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) {
sh "docker pull reg.zknt.org/zknt/toot"
sh 'docker run -i -e CONFIG_JSON=$CONFIG_JSON -e TOOT="Successfully built and pushed new image: '+official_image+':'+timeStamp+' https://hub.docker.com/r/zknt/pixelfed/tags" reg.zknt.org/zknt/toot'
}
}
}
2020-05-28 18:19:38 +02:00
}
options {
buildDiscarder(BuildHistoryManager([
[
conditions: [
BuildResult(matchFailure: true)
],
matchAtMost: 4,
continueAfterMatch: false
],
[
conditions: [
BuildResult(matchSuccess: true)
],
matchAtMost: 4,
continueAfterMatch: false
],
[
conditions: [
BuildResult(matchSuccess: true, matchFailure: true)
],
actions: [DeleteBuild()]
]
]))
}
}