2020-11-26 02:59:36 +00:00
|
|
|
pipeline {
|
|
|
|
agent { label 'linux' }
|
|
|
|
|
2020-11-30 11:59:53 +00:00
|
|
|
options {
|
|
|
|
timestamps()
|
2022-06-08 11:48:30 +00:00
|
|
|
timeout(time: 20, unit: 'MINUTES')
|
2020-11-30 11:59:53 +00:00
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '10',
|
|
|
|
daysToKeepStr: '30',
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2020-11-26 02:59:36 +00:00
|
|
|
parameters {
|
|
|
|
string(
|
2020-11-30 11:59:53 +00:00
|
|
|
name: 'MAKE_TARGET',
|
|
|
|
description: 'Makefile target to build. Optional Parameter.',
|
|
|
|
defaultValue: params.MAKE_TARGET ?: 'wakunode2',
|
2020-11-26 02:59:36 +00:00
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'IMAGE_TAG',
|
2020-11-30 11:59:53 +00:00
|
|
|
description: 'Name of Docker tag to push. Optional Parameter.',
|
2022-09-28 12:31:10 +00:00
|
|
|
defaultValue: params.IMAGE_TAG ?: 'deploy-wakuv2-test',
|
2020-11-26 02:59:36 +00:00
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'IMAGE_NAME',
|
2020-11-30 11:59:53 +00:00
|
|
|
description: 'Name of Docker image to push.',
|
|
|
|
defaultValue: params.IMAGE_NAME ?: 'statusteam/nim-waku',
|
2020-11-26 02:59:36 +00:00
|
|
|
)
|
|
|
|
string(
|
2022-05-17 19:11:07 +00:00
|
|
|
name: 'NIMFLAGS',
|
2020-11-30 11:59:53 +00:00
|
|
|
description: 'Flags for Nim compilation.',
|
2022-07-22 11:45:47 +00:00
|
|
|
defaultValue: params.NIMFLAGS ?: [
|
|
|
|
'--colors:off',
|
|
|
|
'-d:disableMarchNative',
|
|
|
|
'-d:chronicles_colors:none',
|
|
|
|
'-d:insecure',
|
|
|
|
].join(' ')
|
2020-11-26 02:59:36 +00:00
|
|
|
)
|
2022-12-01 10:28:09 +00:00
|
|
|
booleanParam(
|
|
|
|
name: 'EXPERIMENTAL',
|
|
|
|
description: 'Enable experimental features.',
|
|
|
|
defaultValue: false
|
|
|
|
)
|
2020-11-26 02:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Build') {
|
|
|
|
steps { script {
|
|
|
|
image = docker.build(
|
2022-12-01 11:45:06 +00:00
|
|
|
"${params.IMAGE_NAME}:${env.GIT_COMMIT.take(8)}" + (params.EXPERIMENTAL ? "-experimental": ""),
|
2022-02-21 15:42:27 +00:00
|
|
|
"--label=commit='${env.GIT_COMMIT.take(8)}' " +
|
2020-11-30 11:59:53 +00:00
|
|
|
"--build-arg=MAKE_TARGET='${params.MAKE_TARGET}' " +
|
2022-12-01 10:28:09 +00:00
|
|
|
"--build-arg=NIMFLAGS='${params.NIMFLAGS}' " +
|
2022-12-01 11:45:06 +00:00
|
|
|
"--build-arg=EXPERIMENTAL='${params.EXPERIMENTAL}' " +
|
2022-12-06 00:18:33 +00:00
|
|
|
"--target=${params.EXPERIMENTAL ? "experimental" : "prod"} ."
|
2020-11-26 02:59:36 +00:00
|
|
|
)
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Push') {
|
|
|
|
steps { script {
|
|
|
|
withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
|
|
|
|
image.push()
|
2020-11-30 11:59:53 +00:00
|
|
|
image.push(env.IMAGE_TAG)
|
2020-11-26 02:59:36 +00:00
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
} // stages
|
|
|
|
post {
|
2022-09-09 08:46:06 +00:00
|
|
|
success { script {
|
2022-10-12 13:31:30 +00:00
|
|
|
discordNotify(
|
|
|
|
header: 'Nim-Waku deployment successful!',
|
|
|
|
cred: 'discord-waku-deployments-webhook',
|
|
|
|
)
|
2022-09-09 08:46:06 +00:00
|
|
|
} }
|
2020-11-26 02:59:36 +00:00
|
|
|
always { sh 'docker image prune -f' }
|
|
|
|
} // post
|
|
|
|
} // pipeline
|
2022-10-12 13:31:30 +00:00
|
|
|
|
|
|
|
def discordNotify(Map args=[:]) {
|
|
|
|
def opts = [
|
|
|
|
header: args.header ?: 'Deployment successful!',
|
|
|
|
cred: args.cred ?: null,
|
|
|
|
]
|
|
|
|
def repo = [
|
|
|
|
url: GIT_URL.minus('.git'),
|
|
|
|
branch: GIT_BRANCH.minus('origin/'),
|
|
|
|
commit: GIT_COMMIT.take(8),
|
|
|
|
prev: (
|
|
|
|
env.GIT_PREVIOUS_SUCCESSFUL_COMMIT ?: env.GIT_PREVIOUS_COMMIT ?: 'master'
|
|
|
|
).take(8),
|
|
|
|
]
|
|
|
|
wrap([$class: 'BuildUser']) {
|
|
|
|
BUILD_USER_ID = env.BUILD_USER_ID
|
|
|
|
}
|
|
|
|
withCredentials([
|
|
|
|
string(
|
|
|
|
credentialsId: opts.cred,
|
|
|
|
variable: 'DISCORD_WEBHOOK',
|
|
|
|
),
|
|
|
|
]) {
|
|
|
|
discordSend(
|
|
|
|
link: env.BUILD_URL,
|
|
|
|
result: currentBuild.currentResult,
|
|
|
|
webhookURL: env.DISCORD_WEBHOOK,
|
|
|
|
title: "${env.JOB_NAME}#${env.BUILD_NUMBER}",
|
|
|
|
description: """
|
|
|
|
${opts.header}
|
|
|
|
Image: [`${IMAGE_NAME}:${IMAGE_TAG}`](https://hub.docker.com/r/${IMAGE_NAME}/tags?name=${IMAGE_TAG})
|
|
|
|
Branch: [`${repo.branch}`](${repo.url}/commits/${repo.branch})
|
|
|
|
Commit: [`${repo.commit}`](${repo.url}/commit/${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})
|
|
|
|
""",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|