From 89d7ae3a598d426c5d6d9dab91938ba1e1382187 Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <chris.pomeroy@hotmail.com>
Date: Sun, 24 Jan 2021 19:19:53 +0000
Subject: [PATCH] Updated to a generic template

---
 Jenkinsfile |   53 ++++++++++++++++++++++++-----------------------------
 1 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index c5b5853..bfd0e86 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,64 +1,59 @@
-def discordUrl = "https://discordapp.com/api/webhooks/764667082272145418/vorf2JdFG47WAmQP3yZhgHH12wW_qUXG0bS0SG8INLYVwU0HcDFajq9doaDgi_hnI00-"
 def customImage
+def discordUrl = "https://discordapp.com/api/webhooks/764667082272145418/vorf2JdFG47WAmQP3yZhgHH12wW_qUXG0bS0SG8INLYVwU0HcDFajq9doaDgi_hnI00-"
 
-pipeline {
-    agent{ label 'x86-docker-agent'  }
-    options {
-        timestamps()
-        ansiColor("xterm")
+
+pipeline{
+    agent{
+        label "x86-docker-agent"
     }
-
-    environment {
-        BUILDDATE = sh(script: "echo `date --rfc-3339=date`", returnStdout: true).trim()
+    environment{
+        def BUILDDATE = sh(script: "echo `date --rfc-3339=date`", returnStdout: true).trim()
     }
-
-    stages {
-        stage('Checkout Source'){
-            steps {
+    stages{
+        stage ('Checkout source'){
+            steps{
                 checkout scm
             }
             post{
                 failure {
-                    discordSend description:" Failed to checkout source code ", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
+                    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 {
-                    customImage = docker.build("jenkins:${env.BUILDDATE}-build-${env.BUILD_ID}")
+        stage ('Build image'){    
+            steps{
+                script{
+                    customImage = docker.build("${JOB_NAME}:${BUILDDATE}-build-${env.BUILD_ID}")
                 }
             }
             post{
                 failure {
-                    discordSend description:" Building image failed ", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
+                    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 to repository'){
-            steps {
-                script {
+        stage('Push Image'){
+           steps{
+               script{
                     docker.withRegistry('https://dev-reg.darkurthe.net'){
                         customImage.push()
                         customImage.push("latest")
                     }
-                }
+               }
             }
             post{
                 failure {
-                    discordSend description: " Pushing image failed ", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
+                    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 Jenkins image has been pushed to the registry ", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"       
+            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 Jenkins docker image.\nPlease review the build", footer: "Jenkins docker image", link: "${env.BUILD_URL}", title: "${JOB_NAME}", result: "${currentBuild.currentResult}", webhookURL: "${discordUrl}"
+            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}"
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.10.0