Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-sb-devops
Commits
500f4c6f
Commit
500f4c6f
authored
5 years ago
by
Himanshu-optit
Committed by
Keshav Prasad
5 years ago
Browse files
Options
Download
Patches
Plain Diff
Shared lib 2 (#751)
* Update slack_notify.groovy
parent
c7179be5
shared-lib_627aacd
release-3.4.0-shared-lib
release-2.7.0-shared-lib
release-2.6.0-shared-lib
release-2.5.0-shared-lib
release-2.4.0-shared-lib
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vars/slack_notify.groovy
+38
-33
vars/slack_notify.groovy
with
38 additions
and
33 deletions
+38
-33
vars/slack_notify.groovy
+
38
−
33
View file @
500f4c6f
def
call
()
{
try
{
ansiColor
(
'xterm'
)
{
String
ANSI_GREEN
=
"\u001B[32m"
String
ANSI_NORMAL
=
"\u001B[0m"
String
ANSI_BOLD
=
"\u001B[1m"
String
ANSI_RED
=
"\u001B[31m"
String
ANSI_YELLOW
=
"\u001B[33m"
println
"In slack"
stage
(
'slack_notify'
)
{
mainDir
=
sh
(
returnStdout:
true
,
script:
"echo $JOB_NAME"
).
split
(
'/'
)[-
4
].
trim
()
println
mainDir
slack_channel
=
mainDir
.
toUpperCase
()
+
"_NOTIFY_SLACK_CHANNEL"
println
slack_channel
println
"$slack_channel"
if
(
slack_channel
!=
null
)
slackSend
(
channel:
slack_channel
,
color:
'danger'
,
message:
"Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
else
if
(
env
.
GLOBAL_NOTIFY_SLACK_CHANNEL
!=
null
)
slackSend
(
def
call
(
String
status
)
{
try
{
ansiColor
(
'xterm'
)
{
String
ANSI_GREEN
=
"\u001B[32m"
String
ANSI_NORMAL
=
"\u001B[0m"
String
ANSI_BOLD
=
"\u001B[1m"
String
ANSI_RED
=
"\u001B[31m"
String
ANSI_YELLOW
=
"\u001B[33m"
stage
(
'slack_notify'
)
{
mainDir
=
sh
(
returnStdout:
true
,
script:
"echo $JOB_NAME"
).
split
(
'/'
)[-
4
].
trim
()
slack_channel
=
mainDir
.
toUpperCase
()
+
"_NOTIFY_SLACK_CHANNEL"
if
(
status
==
"FAILURE"
){
slack_status
=
'danger'
build_status
=
"Failed"
}
else
{
slack_status
=
'green'
build_status
=
"Succeded"
}
if
(
slack_channel
!=
null
)
slackSend
(
channel:
slack_channel
,
color:
slack_status
,
message:
"Build ${build_status} - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
else
if
(
env
.
GLOBAL_NOTIFY_SLACK_CHANNEL
!=
null
)
slackSend
(
channel:
"${env.GLOBAL_NOTIFY_SLACK_CHANNEL}"
,
color:
'danger'
,
message:
"Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
else
println
ANSI_YELLOW
+
ANSI_BOLD
+
"Could not find slack environment variable. Skipping slack notification.."
+
ANSI_NORMAL
color:
slack_status
,
message:
"Build ${build_status} - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
else
println
ANSI_YELLOW
+
ANSI_BOLD
+
"Could not find slack environment variable. Skipping slack notification.."
+
ANSI_NORMAL
}
}
}
catch
(
err
){
throw
err
}
}
catch
(
err
){
throw
err
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets