From 5cbf3ee4f598fefceb1b9e181e502666d11c74ab Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <chris.pomeroy@hotmail.com>
Date: Sun, 11 Oct 2020 19:10:49 +0000
Subject: [PATCH] Fixed the agent syntax
---
Jenkinsfile | 78 +++++++++++++++++++++++++++++---------
1 files changed, 59 insertions(+), 19 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 827045d..c0ba2d0 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,24 +1,64 @@
-node('pi-docker-agent') {
- def customImage
- def BUILDDATE = sh(script: "echo `date --rfc-3339=date`", returnStdout: true).trim()
+def discordUrl = "https://discordapp.com/api/webhooks/764667082272145418/vorf2JdFG47WAmQP3yZhgHH12wW_qUXG0bS0SG8INLYVwU0HcDFajq9doaDgi_hnI00-"
+def BUILDDATE = sh(script: "echo `date --rfc-3339=date`", returnStdout: true).trim()
+def customImage
- stage ('Checkout source'){
- checkout scm
- }
-
- stage ('Build image'){
- //Build the image
- customImage = docker.build("jenkins:${BUILDDATE}-build-${env.BUILD_ID}")
- }
- stage('Test Image'){
- customImage.inside {
- sh 'curl -s -o /dev/null -w "%{http_code}" localhost:8080/login'
+pipeline {
+ agent {
+ label 'pi-docker-agent'
+
+ options {
+ timestamps()
+ // ansiColor("xterm")
}
}
- stage('Push Image'){
- docker.withRegistry('https://dev-reg.darkurthe.net'){
- customImage.push()
- customImage.push("latest")
+
+ 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}"
+ }
+ }
+ }
+
+ stage('Build Image'){
+ steps {
+ script {
+ docker.build("jenkins:${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}"
+ }
+ }
+ }
+
+ stage('Push Image to repository'){
+ 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}"
+ }
+ }
}
}
-}
+ 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}"
+ }
+ 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}"
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.10.0