85 lines
3.1 KiB
Groovy
85 lines
3.1 KiB
Groovy
pipeline {
|
|
agent { label 'docker' }
|
|
|
|
environment {
|
|
DOCKER_REGISTRY = "docker.nclazz.de"
|
|
DOCKER_IMAGE_NAME = "nclazz/static-webserver:latest"
|
|
}
|
|
|
|
stages {
|
|
stage('Build Docker Image') {
|
|
steps {
|
|
script {
|
|
docker.withRegistry("https://$DOCKER_REGISTRY", "jenkins_nexus") {
|
|
sh 'docker build --tag $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME .'
|
|
sh 'docker push $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME'
|
|
sh 'docker rmi $(docker images --filter "dangling=true" -q --no-trunc)'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
cleanWs()
|
|
}
|
|
failure {
|
|
slackSend(
|
|
channel: "notifications",
|
|
color: "danger",
|
|
message: "There is a *build failure* in ${env.JOB_NAME}.\nBuild: ${env.BUILD_URL} "
|
|
)
|
|
emailext(
|
|
recipientProviders: [developers()],
|
|
from: "jenkins@nclazz.de",
|
|
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} failed",
|
|
body: """
|
|
There is a build failure in ${env.JOB_NAME}.
|
|
Build: ${env.BUILD_URL}
|
|
Logs: ${env.BUILD_URL}console
|
|
Changes: ${env.BUILD_URL}changes
|
|
--
|
|
"""
|
|
)
|
|
}
|
|
unstable {
|
|
slackSend(
|
|
channel: "notifications",
|
|
color: "warning",
|
|
message: "Some tests have failed in ${env.JOB_NAME}.\nBuild: ${env.BUILD_URL} "
|
|
)
|
|
emailext(
|
|
recipientProviders: [developers()],
|
|
from: "jenkins@nclazz.de",
|
|
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} unstable",
|
|
body: """
|
|
Some tests have failed in ${env.JOB_NAME}.
|
|
Build: ${env.BUILD_URL}
|
|
Logs: ${env.BUILD_URL}console
|
|
Changes: ${env.BUILD_URL}changes
|
|
--
|
|
"""
|
|
)
|
|
}
|
|
fixed {
|
|
slackSend(
|
|
channel: "notifications",
|
|
color: "good",
|
|
message: "The build ${env.JOB_NAME} completed successfully and is back to normal.\nBuild: ${env.BUILD_URL} "
|
|
)
|
|
emailext(
|
|
recipientProviders: [developers()],
|
|
from: "jenkins@nclazz.de",
|
|
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} fixed",
|
|
body: """
|
|
The build ${env.JOB_NAME} completed successfully and is back to normal.
|
|
|
|
Build: ${env.BUILD_URL}
|
|
Logs: ${env.BUILD_URL}console
|
|
Changes: ${env.BUILD_URL}changes
|
|
--
|
|
"""
|
|
)
|
|
}
|
|
}
|
|
} |