mirror of https://github.com/status-im/go-waku.git
ci: separate discord notification into a function
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
8f783aac25
commit
d4018d3f55
|
@ -61,37 +61,50 @@ pipeline {
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
success { script {
|
success { script {
|
||||||
withCredentials([
|
discordNotify(
|
||||||
string(
|
header: 'Go-Waku deployment successful!',
|
||||||
credentialsId: 'discord-waku-deployments-webhook',
|
cred: 'discord-waku-deployments-webhook',
|
||||||
variable: 'DISCORD_WEBHOOK'
|
)
|
||||||
),
|
} }
|
||||||
]) {
|
always { cleanWs() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def discordNotify(Map args=[:]) {
|
||||||
|
def opts = [
|
||||||
|
header: args.header ?: 'Deployment successful!',
|
||||||
|
cred: args.cred ?: null,
|
||||||
|
]
|
||||||
def repo = [
|
def repo = [
|
||||||
url: 'https://github.com/status-im/go-waku',
|
url: GIT_URL.minus('.git'),
|
||||||
branch: GIT_BRANCH.minus("origin/"),
|
branch: GIT_BRANCH.minus('origin/'),
|
||||||
commit: GIT_COMMIT.take(8),
|
commit: GIT_COMMIT.take(8),
|
||||||
prev: (env.GIT_PREVIOUS_SUCCESSFUL_COMMIT ?: env.GIT_PREVIOUS_COMMIT ?: 'master').take(8),
|
prev: (
|
||||||
|
env.GIT_PREVIOUS_SUCCESSFUL_COMMIT ?: env.GIT_PREVIOUS_COMMIT ?: 'master'
|
||||||
|
).take(8),
|
||||||
]
|
]
|
||||||
wrap([$class: 'BuildUser']) {
|
wrap([$class: 'BuildUser']) {
|
||||||
BUILD_USER_ID = env.BUILD_USER_ID
|
BUILD_USER_ID = env.BUILD_USER_ID
|
||||||
}
|
}
|
||||||
|
withCredentials([
|
||||||
|
string(
|
||||||
|
credentialsId: opts.cred,
|
||||||
|
variable: 'DISCORD_WEBHOOK',
|
||||||
|
),
|
||||||
|
]) {
|
||||||
discordSend(
|
discordSend(
|
||||||
|
link: env.BUILD_URL,
|
||||||
|
result: currentBuild.currentResult,
|
||||||
|
webhookURL: env.DISCORD_WEBHOOK,
|
||||||
title: "${env.JOB_NAME}#${env.BUILD_NUMBER}",
|
title: "${env.JOB_NAME}#${env.BUILD_NUMBER}",
|
||||||
description: """
|
description: """
|
||||||
Go-Waku deployment successful!
|
${opts.header}
|
||||||
Image: [`${IMAGE_NAME}:${IMAGE_TAG}`](https://hub.docker.com/r/${IMAGE_NAME}/tags?name=${IMAGE_TAG})
|
Image: [`${IMAGE_NAME}:${IMAGE_TAG}`](https://hub.docker.com/r/${IMAGE_NAME}/tags?name=${IMAGE_TAG})
|
||||||
Branch: [`${repo.branch}`](${repo.url}/commits/${repo.branch})
|
Branch: [`${repo.branch}`](${repo.url}/commits/${repo.branch})
|
||||||
Commit: [`${repo.commit}`](${repo.url}/commit/${repo.commit})
|
Commit: [`${repo.commit}`](${repo.url}/commit/${repo.commit})
|
||||||
Diff: [`${repo.prev}...${repo.commit}`](${repo.url}/compare/${repo.prev}...${repo.commit})
|
Diff: [`${repo.prev}...${repo.commit}`](${repo.url}/compare/${repo.prev}...${repo.commit})
|
||||||
By: [`${BUILD_USER_ID}`](${repo.url}/commits?author=${BUILD_USER_ID})
|
By: [`${BUILD_USER_ID}`](${repo.url}/commits?author=${BUILD_USER_ID})
|
||||||
""",
|
""",
|
||||||
link: env.BUILD_URL,
|
|
||||||
result: currentBuild.currentResult,
|
|
||||||
webhookURL: env.DISCORD_WEBHOOK
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} }
|
|
||||||
always { cleanWs() }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue