Skip to content

Commit

Permalink
Merge pull request #3 from rundeck-plugins/overwrite-config-project
Browse files Browse the repository at this point in the history
set default properties at project/framework level
  • Loading branch information
ltamaster authored Oct 30, 2018
2 parents bc06c98 + 923397c commit 973743c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ See the [Included Plugins | Rundeck Documentation](http://rundeck.org/docs/plugi

## Download jarfile

1. Download jarfile from [releases](https://github.com/higanworks/rundeck-slack-incoming-webhook-plugin/releases).
1. Download jarfile from [releases](https://github.com/rundeck-plugins/slack-incoming-webhook-plugin/releases).
2. copy jarfile to `$RDECK_BASE/libext`

## Build
Expand Down
34 changes: 33 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
plugins {
id 'java'
id 'pl.allegro.tech.build.axion-release' version '1.7.1'
}

apply plugin: 'java'
apply plugin: 'pl.allegro.tech.build.axion-release'

sourceCompatibility = 1.6
project.version = 1.0
defaultTasks 'clean', 'build'

configurations{
Expand All @@ -13,6 +19,32 @@ configurations{
}
}

scmVersion {
ignoreUncommittedChanges = false
tag {
prefix = 'v'
versionSeparator = ''
def origDeserialize=deserialize

//apend .0 to satisfy semver if the tag version is only X.Y
deserialize = { config, position, tagName ->
println("config:" + config)
println("position:" + position)
println("tagName:" + tagName)
def orig = origDeserialize(config, position, tagName)
println("orig:" + orig)
if (orig.split('\\.').length < 3) {
orig += ".0"
}
println("orig2:" + orig)
orig
}
}
}

println("scmVersion.version:" + scmVersion.version)
project.version = scmVersion.version

repositories {
mavenCentral()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,21 @@ public class SlackNotificationPlugin implements NotificationPlugin {

private static final Configuration FREEMARKER_CFG = new Configuration();

@PluginProperty(title = "WebHook Base URL", description = "Slack Incoming WebHook Base URL", required = true, defaultValue = "https://hooks.slack.com/services")
@PluginProperty(title = "WebHook Base URL",
description = "Slack Incoming WebHook Base URL",
defaultValue = "https://hooks.slack.com/services",
scope=PropertyScope.Instance)
private String webhook_base_url;

@Password
@PluginProperty(title = "WebHook Token", description = "WebHook Token, like T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", required = true)
@PluginProperty(title = "WebHook Token",
description = "WebHook Token, like T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
scope=PropertyScope.Instance)
private String webhook_token;

@PluginProperty(title = "Slack Channel", description = "Slack Channel, like #channel-name (optional)")
@PluginProperty(title = "Slack Channel",
description = "Slack Channel, like #channel-name (optional)",
scope=PropertyScope.Instance)
private String slack_channel;

/**
Expand Down Expand Up @@ -107,6 +114,10 @@ public boolean postNotification(String trigger, Map executionData, Map config) {
throw new IllegalArgumentException("Unknown trigger type: [" + trigger + "].");
}

if(this.webhook_base_url.isEmpty() || this.webhook_token.isEmpty()){
throw new IllegalArgumentException("URL or Token not set");
}

String webhook_url=this.webhook_base_url+"/"+this.webhook_token;

String message = generateMessage(trigger, executionData, config, this.slack_channel);
Expand Down
Binary file added src/main/resources/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 973743c

Please sign in to comment.