From 93be24a8de61f55a3f17bb6cbdc5ddc5368263b5 Mon Sep 17 00:00:00 2001 From: Jared Date: Tue, 1 Jul 2025 09:19:09 +0200 Subject: [PATCH] added check if pipeline job was running --- Jenkinsfile | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 817e3de..95efcf4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +def runJobs = false + pipeline { agent any @@ -30,6 +32,9 @@ pipeline { steps { sh 'npm ci' } + post { + runJobs = true + } } stage('Test & Security Audit') { @@ -37,30 +42,37 @@ pipeline { echo 'Start checking security vulnerabilities in npm packages' sh 'npm audit --audit-level=moderate' } + post { + runJobs = true + } } stage('Push image to gitea registry') { steps { - echo 'Start Pushing' script { - def tag = "innohub/tatort-dev:${env.BUILD_ID}" + def tag = "innohub/tatort-dev:0.${env.BUILD_ID}" docker.withRegistry('https://gitea.innovation-hub-niedersachsen.de', 'JenkinsGitea') { docker.build(tag, '-f Dockerfile.dev .').push() } } + post { + runJobs = true + } } } } post { - success { - echo 'Pipeline erfolgreich!' - discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline succeeded', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc' - } + if (runJobs) { + success { + echo 'Pipeline erfolgreich!' + discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline succeeded', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc' + } - failure { - echo 'Pipeline fehlgeschlagen!' - discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline failed', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc' + failure { + echo 'Pipeline fehlgeschlagen!' + discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline failed', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc' + } } } }