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 ability for environment variables and parameters #80

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
023c164
Merge pull request #5 from Litterfeldt/master
grantmd Jan 24, 2014
88d6f07
?
grantmd Feb 19, 2014
63159fb
Merge pull request #1 from tinyspeck/master
grantmd Feb 19, 2014
7abe96b
?
grantmd Feb 19, 2014
2edef4a
Using username/password for auth if specified.
batmat Jul 2, 2014
5dc124e
Merge pull request #14 from Batmat/support-authenticated-proxy
grantmd Jul 2, 2014
d69f05f
Log when posting succeeded
grantmd Jul 2, 2014
671d173
Clean
grantmd Jul 2, 2014
e97e9b3
Team domain and integration token per project (moved from global sett…
idserda Aug 15, 2014
eb5fb05
Send message using attachment with color.
hSATAC Aug 20, 2014
8050978
Merge pull request #20 from hSATAC/feature/attachment-with-color
grantmd Sep 7, 2014
de2d7ca
Report 'return to normal' on transition from unstable to success as well
tbartley Oct 2, 2014
3ab816b
Merge remote-tracking branch 'jenkins/master' into multiple-teams
idserda Oct 10, 2014
412d497
Global settings + per project override for teamdomain, token and channel
idserda Oct 11, 2014
9bfc772
formatting cleanup
idserda Oct 11, 2014
56751ea
add fallback to attachment (used by notifications)
idserda Oct 11, 2014
d2e72c2
Add a method to append test summary to build notifications
randomsync Oct 15, 2014
891e600
Add a checkbox to specify including test summary in notifications
randomsync Oct 17, 2014
a4f2261
Fix for a missed change to notifyStart method
randomsync Oct 20, 2014
ffccb35
apply global config
toshihirock Oct 26, 2014
68b6459
[FIXED JENKINS-26066] Add null check and log
timp21337 Dec 15, 2014
0884547
Make start notifications use the color of the last build's result
Jan 27, 2015
0fa0461
Handle case on first build where previous build is null
Jan 30, 2015
5917fa5
Removing mixed tabs in pom.xml
samrocketman Jan 31, 2015
483215a
Adding Sam Gleske as maintainer to pom.xml
samrocketman Jan 31, 2015
d30ce44
WORKAROUND: Adding JNA as a dependency
samrocketman Jan 31, 2015
9766dcc
Clean up indenting in pom.xml
samrocketman Jan 31, 2015
04dfb71
README: Add build instructions
samrocketman Jan 31, 2015
5bafe2b
Use HPI not JAR in Jenkins
samrocketman Jan 31, 2015
f506fe1
Merge #26 apply global config fixes #12
samrocketman Feb 1, 2015
c3a22de
Merge PR #19 Team domain and token per project
samrocketman Feb 1, 2015
03ca923
Merge PR #43 start notifications use the color of
samrocketman Feb 1, 2015
867f85c
Merge PR #21 Report 'return to normal' on
samrocketman Feb 1, 2015
6b77dff
Merge PR #35 Add null check and log
samrocketman Feb 1, 2015
84ac191
Merge PR #24 add fallback to attachment
samrocketman Feb 1, 2015
2dcbd68
Merge PR #25 Include test summary in build
samrocketman Feb 1, 2015
583f75e
Updated to show the list of commits (title+author)
peergum Nov 24, 2014
95cadc0
Merge PR #30 Updated to show the list of commits
samrocketman Feb 2, 2015
f070f74
Combine advanced sections at the bottom of Slack
samrocketman Feb 2, 2015
a2cfc25
Patching #30: Always show commit list in slack
peergum Feb 4, 2015
54cd9bc
Merge PR #44 Patching #30: Always show user list
samrocketman Feb 4, 2015
d2bd757
Fix to avoid a bug when there are no changes in commit list
Feb 4, 2015
b598c88
Merge #45 Fix to avoid a bug when there are no
samrocketman Feb 4, 2015
32ef7d7
[JENKINS-15][JENKINS-28] Added option to notify repeated failure
peergum Feb 5, 2015
f0204e7
Merge PR #46 Added option to notify repeated
samrocketman Feb 10, 2015
cbe01c5
Preparing for 1.7 release
samrocketman Feb 10, 2015
12dfe59
[maven-release-plugin] prepare release slack-1.7
samrocketman Feb 16, 2015
9a6f73a
[maven-release-plugin] prepare for next development iteration
samrocketman Feb 16, 2015
bd0b483
Add build status to README
samrocketman Feb 27, 2015
c242747
Merge pull request #53 from jenkinsci/build_status
samrocketman Feb 27, 2015
ff686a7
#55: update separator for multi-channel posts
peergum Mar 1, 2015
e8370a5
Notifications start with full project name
dave-miles Mar 5, 2015
d6eed93
fix parameter order
graphaelli Mar 5, 2015
7f50d8f
Merge PR #63 fix test summary / notify repeated
samrocketman Mar 6, 2015
f861efe
Move test connection button to advanced section
samrocketman Mar 6, 2015
fdd67e9
Merge PR #61 Notifications start with full project
samrocketman Mar 6, 2015
c628842
Merge PR #56 Multiple channel post using comma,
samrocketman Mar 6, 2015
128f54a
Merge pull request #64 from jenkinsci/test_conn_advanced
samrocketman Mar 6, 2015
51485a8
Clarification for newbies like me
hhaamm Mar 30, 2015
b766f3f
Merge pull request #74 from hhaamm/master
samrocketman Mar 30, 2015
753ad6a
Adding ability for environment variables and parameters: https://gith…
Brantone Apr 9, 2015
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
8 changes: 4 additions & 4 deletions src/main/java/jenkins/plugins/slack/ActiveNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void started(AbstractBuild build) {
}

private void notifyStart(AbstractBuild build, String message) {
getSlack(build).publish(message, "green");
getSlack(build).publish(message, "good");
}

public void finalized(AbstractBuild r) {
Expand Down Expand Up @@ -106,11 +106,11 @@ String getChanges(AbstractBuild r) {
static String getBuildColor(AbstractBuild r) {
Result result = r.getResult();
if (result == Result.SUCCESS) {
return "green";
return "good";
} else if (result == Result.FAILURE) {
return "red";
return "danger";
} else {
return "yellow";
return "warning";
}
}

Expand Down
19 changes: 16 additions & 3 deletions src/main/java/jenkins/plugins/slack/StandardSlackService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.commons.httpclient.methods.PostMethod;

import org.json.JSONObject;
import org.json.JSONArray;

import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -31,7 +32,7 @@ public StandardSlackService(String teamDomain, String token, String roomId) {
}

public void publish(String message) {
publish(message, "yellow");
publish(message, "warning");
}

public void publish(String message, String color) {
Expand All @@ -43,9 +44,21 @@ public void publish(String message, String color) {
JSONObject json = new JSONObject();

try {
JSONObject field = new JSONObject();
field.put("short", false);
field.put("value", message);

JSONArray fields = new JSONArray();
fields.put(field);

JSONObject attachment = new JSONObject();
attachment.put("color", color);
attachment.put("fields", fields);
JSONArray attachments = new JSONArray();
attachments.put(attachment);

json.put("channel", roomId);
json.put("text", message);
json.put("color", color);
json.put("attachments", attachments);

post.addParameter("payload", json.toString());
post.getParams().setContentCharset("UTF-8");
Expand Down