Commit d3145729 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: added abstraction layer to social messaging

  -- a boolean parameter should be added to master eNB job
  -- for slack: pipelineUsesSlack
     if not present or false, no message will be sent
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 998a5970
#!/bin/groovy
/* /*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
...@@ -19,6 +20,16 @@ ...@@ -19,6 +20,16 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
// Abstraction function to send social media messages:
// like on Slack or Mattermost
def sendSocialMediaMessage(pipeChannel, pipeColor, pipeMessage) {
if (params.pipelineUsesSlack != null) {
if (params.pipelineUsesSlack) {
slackSend channel: pipeChannel, color: pipeColor, message: pipeMessage
}
}
}
pipeline { pipeline {
agent { agent {
label 'bellatrix' label 'bellatrix'
...@@ -229,9 +240,9 @@ pipeline { ...@@ -229,9 +240,9 @@ pipeline {
echo "This is a MERGE event" echo "This is a MERGE event"
addGitLabMRComment comment: message addGitLabMRComment comment: message
def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")" def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
slackSend channel: 'ci-enb', color: 'good', message: message2 sendSocialMediaMessage('ci-enb', 'good', message2)
} else { } else {
slackSend channel: 'ci-enb', color: 'good', message: message sendSocialMediaMessage('ci-enb', 'good', message)
} }
} }
} }
...@@ -242,9 +253,9 @@ pipeline { ...@@ -242,9 +253,9 @@ pipeline {
echo "This is a MERGE event" echo "This is a MERGE event"
addGitLabMRComment comment: message addGitLabMRComment comment: message
def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")" def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
slackSend channel: 'ci-enb', color: 'danger', message: message2 sendSocialMediaMessage('ci-enb', 'danger', message2)
} else { } else {
slackSend channel: 'ci-enb', color: 'danger', message: message sendSocialMediaMessage('ci-enb', 'danger', message)
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment