Skip to content

Commit b087674

Browse files
author
Marcelo "Ataxexe" Guimarães
authored
Merge pull request #11 from timbayens/feature/add-changes-to-content
Updated notification with the changes made to the current jenkins build
2 parents 28c20bf + 301a820 commit b087674

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Notifications will include:
2727
- The project's name
2828
- The build number
2929
- The build result
30+
- The build's changes
3031
- The build link
3132

3233
If you are receiving notifications through Pushover, the notification will be sent with

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.2.1
4+
5+
- Updated notification with the changes made to the current jenkins build
6+
37
## 1.2.0
48

59
- Added support for broadcasting notifications through `boteco`

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</parent>
1212
<groupId>tools.devnull</groupId>
1313
<artifactId>build-notifications</artifactId>
14-
<version>1.2.0</version>
14+
<version>1.2.1</version>
1515
<packaging>hpi</packaging>
1616

1717
<name>Jenkins Build Notification Plugin</name>

src/main/java/tools/devnull/jenkins/plugins/buildnotifications/BuildNotifier.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828

2929
import hudson.model.AbstractBuild;
3030
import hudson.model.Result;
31+
import hudson.scm.ChangeLogSet;
3132
import jenkins.model.JenkinsLocationConfiguration;
3233

34+
import java.util.Iterator;
3335
import java.util.logging.Logger;
3436

3537
/**
@@ -90,7 +92,21 @@ private void setUrl() {
9092
}
9193

9294
private void setContent() {
93-
message.setContent(result.toString());
95+
if(build.getChangeSet().getItems().length == 0){
96+
message.setContent(result.toString());
97+
} else {
98+
StringBuilder changes = new StringBuilder();
99+
100+
for (Iterator<? extends ChangeLogSet.Entry> i = build.getChangeSet().iterator(); i.hasNext();) {
101+
ChangeLogSet.Entry change = i.next();
102+
changes.append("\n");
103+
changes.append(change.getMsg());
104+
changes.append(" - ");
105+
changes.append(change.getAuthor());
106+
}
107+
108+
message.setContent(String.format("%s%n%s", result.toString(), changes.toString()));
109+
}
94110
}
95111

96112
private void setTitle() {

0 commit comments

Comments
 (0)