def customImage
|
def discordUrl = "https://discordapp.com/api/webhooks/764667082272145418/vorf2JdFG47WAmQP3yZhgHH12wW_qUXG0bS0SG8INLYVwU0HcDFajq9doaDgi_hnI00-"
|
|
|
pipeline{
|
agent{
|
label "x86-docker-agent"
|
}
|
environment{
|
def BUILDDATE = sh(script: "echo `date --rfc-3339=date`", returnStdout: true).trim()
|
def IMAGE_TAG = "${env.BRANCH_NAME != 'master' ? env.BRANCH_NAME : latest }"
|
}
|
stages{
|
stage ('Checkout source'){
|
steps{
|
scmvars = checkout scm
|
}
|
post{
|
failure {
|
discordSend description:"${env.STAGE_NAME} failed code for ${JOB_NAME}", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
|
}
|
}
|
}
|
stage ('Build image'){
|
steps{
|
script{
|
echo scmvars
|
echo "$env.BRANCH_NAME $IMAGE_TAG"
|
customImage = docker.build("${JOB_NAME}:${BUILDDATE}-build-${env.BUILD_ID}","--no-cache .")
|
}
|
}
|
post{
|
failure {
|
discordSend description:"${env.STAGE_NAME} for failed ${JOB_NAME}", footer: "Jenkins agent docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
|
}
|
}
|
}
|
stage('Push Image'){
|
steps{
|
input 'Proceed with push'
|
script{
|
docker.withRegistry('https://dev-reg.darkurthe.net'){
|
customImage.push()
|
customImage.push("$env.IMAGE_TAG")
|
}
|
}
|
}
|
post{
|
failure {
|
discordSend description: "${env.STAGE_NAME} failed for ${JOB_NAME}", footer: "Jenkins agent docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
|
}
|
}
|
}
|
}
|
post{
|
success {
|
discordSend description: " New ${JOB_NAME}:${BUILDDATE}-build-${env.BUILD_ID} image has been pushed to the registry ", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
|
}
|
unsuccessful{
|
discordSend description: " There was a problem with the ${JOB_NAME} docker image.\nPlease review the build", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
|
}
|
}
|
}
|