Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
/releases
/build
/lib

# gradle
gradle/
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This plugin is protected under the [Eclipse Public 1.0 License](http://www.eclip
your own changes to the plugin.

### History
Version 6
- Add Proxy properties
Version 5
- Change from Ant/Ivy to Gradle build tool.
- Reorganized folder structure.
Expand All @@ -43,15 +45,9 @@ This plugin is protected under the [Eclipse Public 1.0 License](http://www.eclip
Version 2
- Community GitHub Release

### How to build the plugin from eclipse client:

1. Expand the Groovy project that you checked-out from example template.
2. Open build.xml file and execute it as an Ant Build operation (Run As -> Ant Build)
3. The built plugin is located at releases/Slack-UCD-vdev.zip

### How to build the plugin from command line:

1. Navigate to the base folder of the project through command line.
2. Make sure that there is build.xml file there, and then execute 'ant' command.
3. The built plugin is located at releases/Slack-UCD-vdev.zip
Note: Edit the Build.xml to change the version 'dev' to a release number.
2. Make sure that there is `build.gradle` file there, and then execute `./gradlew build -PpluginVersion=<VersionNumber>` command.
3. The built plugin is located at `build/distributions/Slack-UCD-<VersionNumber>.zip`

2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ String stripVersion(String fileNameWithVersion) {
int end = fileNameWithVersion.lastIndexOf("-"); //assumes that: name-version.ext. Will not work with name-version-SNAPSHOT.ext
return fileNameWithVersion.substring(0, end) + ext
}

build.finalizedBy distPlugin
172 changes: 172 additions & 0 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/main/zip/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,8 @@
Fix z/OS IBM-1047 encoding error.
Removed unecessary jars.
</release-note>
<release-note plugin-version="6">
Add Proxy properties
</release-note>
</release-notes>
</pluginInfo>
12 changes: 12 additions & 0 deletions src/main/zip/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
<property name="version" required="true">
<property-ui default-value="${p:version.name}" description="The version of the component deployed." hidden="true" label="Version" type="textBox"/>
</property>
<property name="proxyhost" required="false">
<property-ui description="Proxy Host for HTTP." label="Proxy Host" type="textBox"/>
</property>
<property name="proxyport" required="false">
<property-ui description="Proxy Port for HTTP." label="Proxy Port" type="textBox"/>
</property>
</properties>

<post-processing><![CDATA[
Expand Down Expand Up @@ -78,6 +84,12 @@
<property name="attachment" required="true">
<property-ui description="The Attachment JSON Payload to generate the Slack message." label="Attachment Payload" type="textAreaBox"/>
</property>
<property name="proxyhost" required="false">
<property-ui description="Proxy Host for HTTP." label="Proxy Host" type="textBox"/>
</property>
<property name="proxyport" required="false">
<property-ui description="Proxy Port for HTTP." label="Proxy Port" type="textBox"/>
</property>
</properties>
<post-processing><![CDATA[
if (properties.get("exitCode") != 0) {
Expand Down
18 changes: 18 additions & 0 deletions src/main/zip/postToSlack.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.urbancode.air.CommandHelper;
import groovy.json.JsonBuilder

import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.HostConfiguration
import org.apache.commons.httpclient.methods.PostMethod
import org.apache.commons.httpclient.methods.StringRequestEntity

Expand All @@ -33,6 +34,8 @@ final def emoji = props['emoji'];
final def environment = props['environment'];
final def component = props['component'];
final def version = props['version'];
final def proxyHost = props['proxyhost'];
final def proxyPort = props['proxyport'];

def commandHelper = new CommandHelper(workDir);

Expand Down Expand Up @@ -87,6 +90,21 @@ try{
"UTF-8"
);
def http = new HttpClient();

// Set proxy if set
if(proxyHost != null && proxyHost.length() > 1) {

try {
def HostConfiguration hostConfiguration = http.getHostConfiguration();
hostConfiguration.setProxy(proxyHost, proxyPort.toInteger());
http.setHostConfiguration(hostConfiguration);
} catch(Exception e) {
println "[Error] Unable to set proxy: ${e.message}"
println "[Possible Solution] Verify the proxyHost and proxyPort parameters. host=${proxyHost}, port=${proxyPort}"
}

}

def post = new PostMethod(webhook);
post.setRequestEntity(requestEntity);

Expand Down
19 changes: 19 additions & 0 deletions src/main/zip/postToSlackAttachment.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.urbancode.air.AirPluginTool;
import groovy.json.JsonBuilder;
import groovy.json.JsonSlurper;
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.HostConfiguration
import org.apache.commons.httpclient.methods.PostMethod
import org.apache.commons.httpclient.methods.StringRequestEntity

Expand All @@ -24,6 +25,8 @@ final def slackChannels = props['channels'].split(",|\n")*.trim() - "";
final def slackUsername = props['username'];
final def emoji = props['emoji'];
final def slackAttachment = props['attachment'];
final def proxyHost = props['proxyhost'];
final def proxyPort = props['proxyport'];

slackChannels.each { slackChannel ->
slackChannel = URLDecoder.decode(slackChannel, "UTF-8" );
Expand Down Expand Up @@ -79,6 +82,22 @@ slackChannels.each { slackChannel ->
"UTF-8"
);
def http = new HttpClient();


// Set proxy if set
if(proxyHost != null && proxyHost.length() > 1) {

try {
def HostConfiguration hostConfiguration = http.getHostConfiguration();
hostConfiguration.setProxy(proxyHost, proxyPort.toInteger());
http.setHostConfiguration(hostConfiguration);
} catch(Exception e) {
println "[Error] Unable to set proxy: ${e.message}"
println "[Possible Solution] Verify the proxyHost and proxyPort parameters. host=${proxyHost}, port=${proxyPort}"
}

}

def post = new PostMethod(webhook);
post.setRequestEntity(requestEntity);

Expand Down
2 changes: 2 additions & 0 deletions src/main/zip/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
</migrate>
<migrate to-version="5">
</migrate>
<migrate to-version="6">
</migrate>
</plugin-upgrade>