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

Extract sending logic from task #10

Open
ysb33r opened this issue Nov 28, 2019 · 2 comments
Open

Extract sending logic from task #10

ysb33r opened this issue Nov 28, 2019 · 2 comments

Comments

@ysb33r
Copy link

ysb33r commented Nov 28, 2019

Extract sending logic from task and make it available as a utility method on the extension. In this way people can attach it to a build listener instead of executing a task.

@jongyoul
Copy link
Owner

Can you explain it more about it? I couldn't catch up the exact idea.

@ysb33r
Copy link
Author

ysb33r commented Dec 17, 2019

Most of the code in SlackTask.groovy can be a separate utility class. In that way it can then be used by other Gradle entities except for the specific task type.

For instance what if I always want to send a notification irrespective of the build failed or passed? Then I could something like

buildFinished { BuildResult br ->
  if(br.failure) {
    notifySlack( 'The build has failed' )
    br.rethrowFailure()
  } else {
     notifySlack( 'The build has passed' ) 
  }
}

notifySlack would be some function you provide which will do all of the configuration. I just used it as a simplified example.

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

No branches or pull requests

2 participants