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

Adding support for routing Slack webhooks through egress proxy #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This following properties can be set at the framework or project level:
* `webhookUrl` - (required) the incoming webhook URL configured in Slack custom integrations.
* `iconEmoji` - override default bot emoji
* `username` - override default bot username
* `proxyHost` - (optional) egress proxy host if outbound requests need to be proxied.
* `proxyPort` - (required if `proxyHost` is set) egress proxy port.

#### Additional Properties
The following properties are optional, and can be set at the framework/project
Expand Down
11 changes: 11 additions & 0 deletions SlackNotification.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def sendMessage(String url, Map message) {
* @param color the color for the message
*/
def triggerMessage(Map execution, Map config, String defaultColor) {
if (config.proxyHost != null && config.proxyPort != null) {
System.err.println("DEBUG: proxyHost="+config.proxyHost)
System.err.println("DEBUG: proxyPort="+config.proxyPort)
System.getProperties().put("proxySet", "true")
System.getProperties().put("proxyHost", config.proxyHost)
System.getProperties().put("proxyPort", config.proxyPort)
}
def expandedTitle = expandString(config.title, [execution: execution])
def expandedText = expandString(config.additionalText, [execution: execution])
def attachment = [
Expand Down Expand Up @@ -151,6 +158,10 @@ rundeckPlugin(NotificationPlugin) {
defaultValue: false, scope: 'Instance'

color title: 'Color', description: 'Override default message color', scope: 'InstanceOnly'

proxyHost title:"Proxy host", description:"Outbound proxy", scope:"Project", defaultValue:null, required:false

proxyPort title:"Proxy port", description:"Outbound proxy port", scope:"Project", defaultValue:null, required:false
}
onstart { Map executionData, Map configuration ->
triggerMessage(executionData, configuration, 'warning')
Expand Down