Skip to content

Commit 7df7829

Browse files
author
vaibhav.s
committed
miqdigital#25 Remove Slack token form runner properties file
1 parent dae63c0 commit 7df7829

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,19 @@ public void updateStatusInS3AndNotifySlack()
111111
ExecutionInfo executionInfo =
112112
executionInfoGenerator.getBuildExecutionDetails(readProperties, executionOutputPath);
113113

114-
if (StringUtils.isNullOrEmpty(readProperties.getChannelName()) || StringUtils
115-
.isNullOrEmpty(readProperties.getHeimdallBotToken())) {
114+
final 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)) {
116120
throw new NullPointerException(
117-
"Please specify Channel name and Slack bot token in runner properties file");
121+
"Please assign Slack bot token as system property in Jenkins or your machine");
122+
118123
}
119124
final SlackChannelInfo slackChannelInfo =
120125
SlackChannelInfo.builder().channelName(readProperties.getChannelName())
121-
.token(readProperties.getHeimdallBotToken())
122-
.isNotifySlack(readProperties.isNotifySlack()).build();
126+
.token(heimdallSlackToken).isNotifySlack(readProperties.isNotifySlack()).build();
123127

124128
LOGGER.info("Execution info generated Successfully");
125129
if (slackChannelInfo.isNotifySlack) {

heimdall.application/src/main/java/com/miqdigital/utility/ReadProperties.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public class ReadProperties {
2121
*/
2222
private static final Logger LOGGER = LoggerFactory.getLogger(ReadProperties.class);
2323

24-
/**
25-
* The constant heimdallBotToken.
26-
*/
27-
private String heimdallBotToken;
2824
/**
2925
* The constant channelName.
3026
*/
@@ -62,7 +58,6 @@ public ReadProperties(final String filepath) throws IOException {
6258
private void initFields() {
6359
channelName = properties.getProperty("CHANNEL_NAME");
6460
isNotifySlack = Boolean.parseBoolean(properties.getProperty("ISNOTIFYSLACK"));
65-
heimdallBotToken = properties.getProperty("HEIMDALL_BOT_TOKEN");
6661
jiraPrefix = properties.getProperty("JIRA_PREFIX");
6762
s3BucketName = properties.getProperty("S3_BUCKETNAME");
6863
}

heimdall.sample-client/src/test/resources/properties/runner.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
HEIMDALL_BOT_TOKEN=add slack token
21
CHANNEL_NAME=add channel name
32
ISNOTIFYSLACK=true
43
JIRA_PREFIX=add Jira prefix

0 commit comments

Comments
 (0)