Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Add slacking for failed builds #33

wants to merge 2 commits into from

Conversation

mnokka-unikie
Copy link
Contributor

Slacks failed builds to defined channels. Currently dev and priv Jenkins have dedicated Slack channels defined for usage.

Signed-off-by: mnokka-unikie <[email protected]>
@@ -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 == "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

Copy link
Collaborator

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
Comment on lines 155 to 166
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 ]
}
}
Copy link
Collaborator

@henrirosten henrirosten Jun 25, 2024

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 matches ghaf-jenkins-controller-dev

That way, you could greatly simplify the changes required and have all the 'slacking' changes only in the 'post' step.

@mnokka-unikie
Copy link
Contributor Author

closing, changes implemented top of current main in a new PR

@henrirosten
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants