From d065e151b696af061c47645e41eec7fffb22336a Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 10 Mar 2020 00:49:37 +0800 Subject: [PATCH] jenkins: add mattermost notifications --- library/jenkins.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/jenkins.nix b/library/jenkins.nix index 510781b..1b38c6f 100644 --- a/library/jenkins.nix +++ b/library/jenkins.nix @@ -2,6 +2,8 @@ with builtins; +# https://jenkinsci.github.io/job-dsl-plugin/ + { # source container url and credentialsId job = name: @@ -50,6 +52,14 @@ with builtins; in '' pipeline { agent any + post { + failure { + mattermostSend channel: 'notification', color: '#FF0000', message: "Failed to build : [''${env.JOB_NAME}-''${env.BUILD_NUMBER}](''${env.BUILD_URL})" + } + success { + mattermostSend channel: 'jenkins', color: '#00FF00', message: "Successfully build : [''${env.JOB_NAME}-''${env.BUILD_NUMBER}](''${env.JOB_URL})" + } + } stages{ stage('Pull') { steps { @@ -89,6 +99,14 @@ with builtins; dsl = '' pipeline { agent any + post { + failure { + mattermostSend channel: 'notification', color: '#FF0000', message: "Failed to build : [''${env.JOB_NAME}-''${env.BUILD_NUMBER}](''${env.BUILD_URL})" + } + success { + mattermostSend channel: 'jenkins', color: '#00FF00', message: "Successfully build : [''${env.JOB_NAME}-''${env.BUILD_NUMBER}](''${env.JOB_URL})" + } + } stages{ stage('Pull') { steps {