Skip to content

Commit

Permalink
Display plugin version on the administration page
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteGoo committed Feb 8, 2015
1 parent 6a8bd7b commit 474855e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 8 deletions.
7 changes: 7 additions & 0 deletions tcslackbuildnotifier-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
</plugin>
</plugins>

<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<!-- <resources> <resource> <directory>src/main/resources</directory> <filtering>false</filtering>
</resource> <resource> <directory>src/main/teamcity-plugin-resources</directory>
<filtering>true</filtering> <includes> <include>*.xml</include> <include>*.properties</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
import slacknotifications.SlackNotificationProxyConfig;
import slacknotifications.teamcity.Loggers;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class SlackNotificationMainSettings implements MainConfigProcessor {
private static final String NAME = SlackNotificationMainSettings.class.getName();
private SlackNotificationMainConfig slackNotificationMainConfig;
private SBuildServer server;
private ServerPaths serverPaths;
private String version;

public SlackNotificationMainSettings(SBuildServer server, ServerPaths serverPaths){
this.serverPaths = serverPaths;
Expand Down Expand Up @@ -132,4 +139,14 @@ public int getMaxCommitsToDisplay() {
public void refresh() {
this.slackNotificationMainConfig.refresh();
}

public String getPluginVersion() throws IOException {
if(version != null){
return version;
}
Properties props = new Properties();
props.load(SlackNotificationMainSettings.class.getResourceAsStream("/version.txt"));
version = props.getProperty("version");
return version;
}
}
1 change: 1 addition & 0 deletions tcslackbuildnotifier-core/src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${pom.version}
4 changes: 0 additions & 4 deletions tcslackbuildnotifier-core/tcslackbuildnotifier-core.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.2" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.2" level="project" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package slacknotifications.teamcity.extension;

import com.intellij.openapi.util.text.StringUtil;
import jetbrains.buildServer.controllers.admin.AdminPage;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.serverSide.auth.Permission;
Expand All @@ -14,8 +13,10 @@
import slacknotifications.teamcity.settings.SlackNotificationMainSettings;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;

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

try {
model.put("pluginVersion", this.slackMainSettings.getPluginVersion());
} catch (IOException e) {
Loggers.ACTIVITIES.error("Could not retrieve slack plugin version", e);
}

model.put("disabled", !this.slackMainSettings.getEnabled());
model.put("jspHome", this.jspHome);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#slackNotificationErrors ul li {
color: red;
}

.slackNotifierVersionInfo {
color: #888;
font-size: 90%;
float:right;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<div id="settingsContainer">
<form action="${actionUrl}" id="slackNotifierAdminForm" method="post" onsubmit="return SlackNotifierAdmin.save()" >
<div class="editNotificatorSettingsPage">
<div>
<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>
</div>
<c:choose>
<c:when test="${disabled}">
<div class="pauseNote" style="margin-bottom: 1em;">
Expand All @@ -22,6 +25,7 @@
</div>
</c:otherwise>
</c:choose>

<bs:messages key="message" />
<br/>
<div style="slack-config-errors" id="slackNotificationErrors">
Expand Down
3 changes: 0 additions & 3 deletions tcslackbuildnotifier-web-ui/tcslackbuildnotifier-web-ui.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-logging:commons-logging:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: logkit:logkit:1.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: avalon-framework:avalon-framework:4.1.3" level="project" />
<orderEntry type="module" module-name="tcslackbuildnotifier-core" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="module" module-name="tcslackbuildnotifier-core" scope="TEST" production-on-test="" />
Expand Down

0 comments on commit 474855e

Please sign in to comment.