|
9 | 9 | import jetbrains.buildServer.users.SUser; |
10 | 10 | import jetbrains.buildServer.users.UserSet; |
11 | 11 | import jetbrains.buildServer.vcs.SelectPrevBuildPolicy; |
| 12 | +import org.joda.time.Duration; |
| 13 | +import org.joda.time.Period; |
| 14 | +import org.joda.time.format.PeriodFormatter; |
| 15 | +import org.joda.time.format.PeriodFormatterBuilder; |
12 | 16 |
|
13 | 17 | import java.io.BufferedOutputStream; |
14 | 18 | import java.io.IOException; |
@@ -124,10 +128,25 @@ else if( projectSettings != null && projectSettings.getChannel() != null && proj |
124 | 128 |
|
125 | 129 | String message = ""; |
126 | 130 |
|
| 131 | + PeriodFormatter durationFormatter = new PeriodFormatterBuilder() |
| 132 | + .printZeroRarelyFirst() |
| 133 | + .appendHours() |
| 134 | + .appendSuffix(" hour", " hours") |
| 135 | + .appendSeparator(" ") |
| 136 | + .printZeroRarelyLast() |
| 137 | + .appendMinutes() |
| 138 | + .appendSuffix(" minute", "minutes") |
| 139 | + .appendSeparator(" and ") |
| 140 | + .appendSeconds() |
| 141 | + .appendSuffix(" second", " seconds") |
| 142 | + .toFormatter(); |
| 143 | + |
| 144 | + Duration buildDuration = new Duration(1000*build.getDuration()); |
| 145 | + |
127 | 146 | JsonObject payloadObj = new JsonObject(); |
128 | 147 | payloadObj.addProperty("channel" , channel); |
129 | 148 | payloadObj.addProperty("username" , "TeamCity"); |
130 | | - payloadObj.addProperty("text", String.format("Project '%s' built successfully." , build.getFullName())); |
| 149 | + payloadObj.addProperty("text", String.format("Project '%s' built successfully in %s." , build.getFullName() , durationFormatter.print(buildDuration.toPeriod()))); |
131 | 150 | payloadObj.addProperty("icon_url",slackConfig.getLogoUrl()); |
132 | 151 |
|
133 | 152 | if( commitMsg.length() > 0 ) |
|
0 commit comments