shinyproxy-infrascience/Jenkinsfile

68 lines
2.0 KiB
Plaintext
Raw Normal View History

2024-05-14 13:06:38 +02:00
// REMEMBER TO FILL THE environment section with your values.
// the following filed should be filled: imagename, git_url
// REMEMBER to put your Dockerfile in the root folder of your project
// The related jenkinsjob template is here:
pipeline {
agent {
label 'docker'
}
environment {
2024-05-14 19:14:48 +02:00
imagename = "external-services/shinyproxy"
hubname = "hub.dev.d4science.org"
registryUrl = "https://hub.dev.d4science.org"
registryCredential = 'harbor-dev-external-services'
dockerImage = ''
git_url='https://code-repo.d4science.org/InfraScience/shinyproxy-infrascience.git'
2024-05-14 13:06:38 +02:00
}
stages {
2024-05-14 19:14:48 +02:00
// stage('Cloning Git') {
// steps {
// git([url: git_url, branch: 'main', credentialsId: ''])
// }
// }
2024-05-14 13:06:38 +02:00
stage('Building image') {
steps{
script {
dockerImage = docker.build imagename
}
}
}
stage('Deploy Image') {
steps{
script {
2024-05-14 19:14:48 +02:00
docker.withRegistry( registryUrl, registryCredential ) {
2024-05-14 13:06:38 +02:00
dockerImage.push("$BUILD_NUMBER")
2024-05-14 19:14:48 +02:00
dockerImage.push('latest')
2024-05-14 13:06:38 +02:00
}
}
}
}
stage('Remove Unused docker image') {
steps{
2024-05-14 19:14:48 +02:00
sh "docker rmi $hubname/$imagename:$BUILD_NUMBER"
sh "docker rmi $hubname/$imagename:latest"
2024-05-14 13:06:38 +02:00
}
}
}
// post-build actions
post {
success {
2024-05-14 19:14:48 +02:00
echo 'The shinyproxy docker pipeline worked!'
2024-05-14 13:06:38 +02:00
emailext to: 'jenkinsbuilds@d4science.org',
2024-05-14 19:14:48 +02:00
subject: "[Jenkins Docker Pipeline D4S] ${currentBuild.fullDisplayName} build worked",
2024-05-14 13:06:38 +02:00
body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
}
failure {
echo 'The docker pipeline has failed'
emailext attachLog: true,
to: 'jenkinsbuilds@d4science.org',
subject: "[Jenkins DockerPipeline D4S] build ${currentBuild.fullDisplayName} failed for image ${imagename}",
body: "Something is wrong with ${env.BUILD_URL}"
}
}
}
2024-05-14 19:14:48 +02:00