Skip to content

Commit 474855e

Browse files
committed
Display plugin version on the administration page
1 parent 6a8bd7b commit 474855e

8 files changed

Lines changed: 43 additions & 8 deletions

File tree

tcslackbuildnotifier-core/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
</plugin>
3636
</plugins>
3737

38+
<resources>
39+
<resource>
40+
<directory>src/main/resources</directory>
41+
<filtering>true</filtering>
42+
</resource>
43+
</resources>
44+
3845
<!-- <resources> <resource> <directory>src/main/resources</directory> <filtering>false</filtering>
3946
</resource> <resource> <directory>src/main/teamcity-plugin-resources</directory>
4047
<filtering>true</filtering> <includes> <include>*.xml</include> <include>*.properties</include>

tcslackbuildnotifier-core/src/main/java/slacknotifications/teamcity/settings/SlackNotificationMainSettings.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77
import slacknotifications.SlackNotificationProxyConfig;
88
import slacknotifications.teamcity.Loggers;
99

10+
import java.io.File;
11+
import java.io.FileInputStream;
12+
import java.io.FileNotFoundException;
13+
import java.io.IOException;
14+
import java.util.Properties;
15+
1016
public class SlackNotificationMainSettings implements MainConfigProcessor {
1117
private static final String NAME = SlackNotificationMainSettings.class.getName();
1218
private SlackNotificationMainConfig slackNotificationMainConfig;
1319
private SBuildServer server;
1420
private ServerPaths serverPaths;
21+
private String version;
1522

1623
public SlackNotificationMainSettings(SBuildServer server, ServerPaths serverPaths){
1724
this.serverPaths = serverPaths;
@@ -132,4 +139,14 @@ public int getMaxCommitsToDisplay() {
132139
public void refresh() {
133140
this.slackNotificationMainConfig.refresh();
134141
}
142+
143+
public String getPluginVersion() throws IOException {
144+
if(version != null){
145+
return version;
146+
}
147+
Properties props = new Properties();
148+
props.load(SlackNotificationMainSettings.class.getResourceAsStream("/version.txt"));
149+
version = props.getProperty("version");
150+
return version;
151+
}
135152
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=${pom.version}

tcslackbuildnotifier-core/tcslackbuildnotifier-core.iml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
</content>
1313
<orderEntry type="inheritedJdk" />
1414
<orderEntry type="sourceFolder" forTests="false" />
15-
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.5" level="project" />
16-
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.2" level="project" />
17-
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" />
18-
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
1915
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.4" level="project" />
2016
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.5" level="project" />
2117
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.2" level="project" />

tcslackbuildnotifier-web-ui/src/main/java/slacknotifications/teamcity/extension/SlackNotifierAdminPage.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package slacknotifications.teamcity.extension;
22

3-
import com.intellij.openapi.util.text.StringUtil;
43
import jetbrains.buildServer.controllers.admin.AdminPage;
54
import jetbrains.buildServer.serverSide.SBuildServer;
65
import jetbrains.buildServer.serverSide.auth.Permission;
@@ -14,8 +13,10 @@
1413
import slacknotifications.teamcity.settings.SlackNotificationMainSettings;
1514

1615
import javax.servlet.http.HttpServletRequest;
16+
import java.io.IOException;
1717
import java.util.ArrayList;
1818
import java.util.Map;
19+
import java.util.Properties;
1920

2021
/**
2122
* Created by Peter on 24/01/2015.
@@ -77,6 +78,12 @@ public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRe
7778
model.put("encryptedProxyPassword", proxyConfig.getCreds() == null || proxyConfig.getCreds().getPassword() == null ? null : RSACipher.encryptDataForWeb(proxyConfig.getCreds().getPassword()));
7879
model.put("hexEncodedPublicKey", RSACipher.getHexEncodedPublicKey());
7980

81+
try {
82+
model.put("pluginVersion", this.slackMainSettings.getPluginVersion());
83+
} catch (IOException e) {
84+
Loggers.ACTIVITIES.error("Could not retrieve slack plugin version", e);
85+
}
86+
8087
model.put("disabled", !this.slackMainSettings.getEnabled());
8188
model.put("jspHome", this.jspHome);
8289
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
#slackNotificationErrors ul li {
22
color: red;
3+
}
4+
5+
.slackNotifierVersionInfo {
6+
color: #888;
7+
font-size: 90%;
8+
float:right;
39
}

tcslackbuildnotifier-web-ui/src/main/resources/buildServerResources/SlackNotification/slackAdminSettings.jsp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<div id="settingsContainer">
1111
<form action="${actionUrl}" id="slackNotifierAdminForm" method="post" onsubmit="return SlackNotifierAdmin.save()" >
1212
<div class="editNotificatorSettingsPage">
13+
<div>
14+
<span class="slackNotifierVersionInfo">Version: <c:out value='${pluginVersion}'/>&nbsp;<a href="https://github.com/petegoo/tcSlackBuildNotifier" class="helpIcon" style="vertical-align: middle;" target="_blank"><bs:helpIcon/></a></span>
15+
</div>
1316
<c:choose>
1417
<c:when test="${disabled}">
1518
<div class="pauseNote" style="margin-bottom: 1em;">
@@ -22,6 +25,7 @@
2225
</div>
2326
</c:otherwise>
2427
</c:choose>
28+
2529
<bs:messages key="message" />
2630
<br/>
2731
<div style="slack-config-errors" id="slackNotificationErrors">

tcslackbuildnotifier-web-ui/tcslackbuildnotifier-web-ui.iml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
</content>
1414
<orderEntry type="inheritedJdk" />
1515
<orderEntry type="sourceFolder" forTests="false" />
16-
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-logging:commons-logging:1.1" level="project" />
17-
<orderEntry type="library" scope="PROVIDED" name="Maven: logkit:logkit:1.0.1" level="project" />
18-
<orderEntry type="library" scope="PROVIDED" name="Maven: avalon-framework:avalon-framework:4.1.3" level="project" />
1916
<orderEntry type="module" module-name="tcslackbuildnotifier-core" />
2017
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
2118
<orderEntry type="module" module-name="tcslackbuildnotifier-core" scope="TEST" production-on-test="" />

0 commit comments

Comments
 (0)