chore(ci): reuse discord send function from library
Provides more info and requires less boilerplate. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
3f2905817a
commit
bafc6dfb1f
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.6'
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile {
|
||||
|
@ -43,16 +46,16 @@ pipeline {
|
|||
}
|
||||
|
||||
post {
|
||||
failure {
|
||||
always {
|
||||
script {
|
||||
def discord = load "${WORKSPACE}/ci/discord.groovy"
|
||||
discord.sendMessage(header: 'Nightly Fuzztest Failed. Regression files archived as job artifacts')
|
||||
}
|
||||
}
|
||||
success {
|
||||
script {
|
||||
def discord = load "${WORKSPACE}/ci/discord.groovy"
|
||||
discord.sendMessage(header: 'Nightly Fuzztest Passed')
|
||||
discord.send(
|
||||
header: (
|
||||
currentBuild.currentResult == 'SUCCESS' ?
|
||||
'Nightly Fuzztest Passed' :
|
||||
'Nightly Fuzztest Failed. Regression files archived as job artifacts'
|
||||
),
|
||||
cred: 'nomos-node-discord-commits-webhook',
|
||||
)
|
||||
}
|
||||
}
|
||||
cleanup { cleanWs() }
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.6'
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile {
|
||||
|
@ -67,20 +70,13 @@ pipeline {
|
|||
}
|
||||
|
||||
post {
|
||||
failure {
|
||||
script {
|
||||
def report = readFile("${WORKSPACE}/report.txt").trim()
|
||||
def discord = load "${WORKSPACE}/ci/discord.groovy"
|
||||
discord.sendMessage(header: "Nightly Integration Tests Failed: ${report}")
|
||||
}
|
||||
}
|
||||
success {
|
||||
script {
|
||||
def report = readFile('report.txt').trim()
|
||||
def discord = load "${WORKSPACE}/ci/discord.groovy"
|
||||
discord.sendMessage(header: "Nightly Integration Tests Passed: ${report}")
|
||||
}
|
||||
}
|
||||
always { script {
|
||||
def report = readFile("${WORKSPACE}/report.txt").trim()
|
||||
discord.send(
|
||||
header: "Nightly Integration Tests ${currentBuild.currentResult}: ${report}",
|
||||
cred: 'nomos-node-discord-commits-webhook',
|
||||
)
|
||||
} }
|
||||
cleanup { cleanWs() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
def sendMessage(Map args=[:]) {
|
||||
def opts = [
|
||||
header: args.header ?: 'Build succeeded',
|
||||
title: args.title ?: "${env.JOB_NAME}#${env.BUILD_NUMBER}",
|
||||
cred: args.cred ?: 'nomos-node-discord-commits-webhook',
|
||||
]
|
||||
def repo = [
|
||||
url: GIT_URL.minus('.git'),
|
||||
branch: GIT_BRANCH.minus('origin/'),
|
||||
commit: GIT_COMMIT.take(8),
|
||||
]
|
||||
withCredentials([
|
||||
string(
|
||||
credentialsId: opts.cred,
|
||||
variable: 'DISCORD_WEBHOOK',
|
||||
),
|
||||
]) {
|
||||
discordSend(
|
||||
link: env.BUILD_URL,
|
||||
result: currentBuild.currentResult,
|
||||
webhookURL: env.DISCORD_WEBHOOK,
|
||||
title: opts.title,
|
||||
description: """
|
||||
${opts.header}
|
||||
Branch: [`${repo.branch}`](${repo.url}/commits/${repo.branch})
|
||||
Commit: [`${repo.commit}`](${repo.url}/commit/${repo.commit})
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
Loading…
Reference in New Issue