Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 0bfae15

Browse files
authored
Merge pull request #26 from vaibsaraswat/remove_token_from_properties
#25 Remove Slack token form runner properties file
2 parents c64da87 + 022d16e commit 0bfae15

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

heimdall.application/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<environment>${environment}</environment>
9999
<tags>${tags}</tags>
100100
<viewName>${viewName}</viewName>
101+
<HeimdallSlackToken>${HeimdallSlackToken}</HeimdallSlackToken>
101102
</systemPropertyVariables>
102103
</configuration>
103104
</plugin>

heimdall.application/src/main/java/com/miqdigital/reporting/HeimdallReporting.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,22 @@ public void updateStatusInS3AndNotifySlack()
111111
ExecutionInfo executionInfo =
112112
executionInfoGenerator.getBuildExecutionDetails(readProperties, executionOutputPath);
113113

114-
if (StringUtils.isNullOrEmpty(readProperties.getChannelName()) || StringUtils
115-
.isNullOrEmpty(readProperties.getHeimdallBotToken())) {
116-
throw new NullPointerException(
117-
"Please specify Channel name and Slack bot token in runner properties file");
114+
String heimdallSlackToken = System.getProperty("HeimdallSlackToken");
115+
116+
if (StringUtils.isNullOrEmpty(readProperties.getChannelName())) {
117+
throw new NullPointerException("Please specify Slack Channel name in runner properties file");
118+
119+
} else if (StringUtils.isNullOrEmpty(heimdallSlackToken)) {
120+
heimdallSlackToken = readProperties.getHeimdallBotToken();
121+
if (StringUtils.isNullOrEmpty(heimdallSlackToken)) {
122+
throw new NullPointerException(
123+
"Please assign Slack bot token as system property in Jenkins or in runner properties "
124+
+ "file");
125+
}
118126
}
119127
final SlackChannelInfo slackChannelInfo =
120128
SlackChannelInfo.builder().channelName(readProperties.getChannelName())
121-
.token(readProperties.getHeimdallBotToken())
122-
.isNotifySlack(readProperties.isNotifySlack()).build();
129+
.token(heimdallSlackToken).isNotifySlack(readProperties.isNotifySlack()).build();
123130

124131
LOGGER.info("Execution info generated Successfully");
125132
if (slackChannelInfo.isNotifySlack) {

0 commit comments

Comments
 (0)