-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add slacking for failed builds #33
Conversation
Signed-off-by: mnokka-unikie <[email protected]>
ghaf-main-pipeline.groovy
Outdated
@@ -39,8 +39,26 @@ pipeline { | |||
script { | |||
env.TARGET_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim() | |||
env.ARTIFACTS_REMOTE_PATH = "${env.JOB_NAME}/build_${env.BUILD_ID}-commit_${env.TARGET_COMMIT}" | |||
env.GITHUBLINK="https://github.com/tiiuae/ghaf/commit/${env.TARGET_COMMIT}" | |||
env.SERVER_NAME = sh(script: 'echo ${JENKINS_URL}', returnStdout: true).trim() | |||
if (env.SERVER_NAME == "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Not only here, but throughout the changes you have made.
utils.groovy
Outdated
def determine_environment(serverName) { | ||
def DEV_SLACK_CHANNEL = "ghaf-jenkins-builds-failed" | ||
def PROD_SLACK_CHANNEL = "FALSE" // no slacking | ||
def PRIVATE_SLACK_CHANNEL = "ghaf-jenkins-ci" | ||
if (serverName.contains('prod')) { | ||
return [env: 'prod', channel:PROD_SLACK_CHANNEL ] | ||
} else if (serverName.contains('dev')) { | ||
return [env: 'dev', channel:DEV_SLACK_CHANNEL ] | ||
} else { | ||
return [env:'priv', channel:PRIVATE_SLACK_CHANNEL ] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several problems with this function, most importantly, I don't think we can generally conclude the environment type based on the hostname or jenkins URL alone. I would propose the following:
- Completely remove this function
- Start with adding 'slacking' feature to one pipeline, perhaps to the
ghaf-main-pipeline.groovy
- In the post step of the given pipeline, determine if 'slacking' is needed based on the hostname strict match (as returned by
uname -n
). Only proceed with 'slacking' if hostname matchesghaf-jenkins-controller-dev
That way, you could greatly simplify the changes required and have all the 'slacking' changes only in the 'post' step.
Signed-off-by: mnokka-unikie <[email protected]>
closing, changes implemented top of current main in a new PR |
@mnokka-unikie : generally, you don't need to introduce a new PR to have it rebased on the new main. Simply rebase locally, then force-push to your branch and it will update the PR too. |
Slacks failed builds to defined channels. Currently dev and priv Jenkins have dedicated Slack channels defined for usage.