nwaku/ci/Jenkinsfile.release

113 lines
2.8 KiB
Plaintext
Raw Normal View History

pipeline {
agent { label 'linux' }
options {
timestamps()
timeout(time: 20, unit: 'MINUTES')
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
))
}
parameters {
string(
name: 'MAKE_TARGET',
description: 'Makefile target to build. Optional Parameter.',
defaultValue: params.MAKE_TARGET ?: 'wakunode2',
)
string(
name: 'IMAGE_TAG',
description: 'Name of Docker tag to push. Optional Parameter.',
defaultValue: getDefaultImageTag()
)
string(
name: 'IMAGE_NAME',
description: 'Name of Docker image to push.',
defaultValue: params.IMAGE_NAME ?: 'wakuorg/nwaku',
)
string(
name: 'DOCKER_CRED',
description: 'Name of Docker Hub credential.',
defaultValue: params.DOCKER_CRED ?: 'dockerhub-vacorgbot-api-token',
)
string(
name: 'NIMFLAGS',
description: 'Flags for Nim compilation.',
defaultValue: params.NIMFLAGS ?: [
'--colors:off',
'-d:disableMarchNative',
'-d:chronicles_colors:none',
'-d:insecure',
'-d:postgres',
].join(' ')
)
string(
name: "LOG_LEVEL",
description: "Chronicles log level (default: TRACE)",
)
booleanParam(
name: 'DEBUG',
description: 'Enable debug features (heaptrack).',
defaultValue: false
)
}
stages {
stage('Build') {
steps { script {
image = docker.build(
"${params.IMAGE_NAME}:${env.GIT_COMMIT.take(8)}",
"--label=commit='${env.GIT_COMMIT.take(8)}' " +
"--build-arg=MAKE_TARGET='${params.MAKE_TARGET}' " +
"--build-arg=NIMFLAGS='${params.NIMFLAGS}' " +
(params.LOG_LEVEL != null ? "--build-arg=LOG_LEVEL='${params.LOG_LEVEL}' ": "") +
"--target=${params.DEBUG ? "debug" : "prod"} ."
)
} }
}
stage('Check') {
steps { script {
image.inside('--entrypoint=""') { c ->
sh '/usr/bin/wakunode --version'
}
} }
}
stage('Push') {
when { expression { params.IMAGE_TAG != '' } }
steps { script {
withDockerRegistry([
credentialsId: params.DOCKER_CRED, url: ""
]) {
image.push()
image.push(env.IMAGE_TAG)
}
} }
}
} // stages
post {
success { script {
def discord = load 'ci/discord.groovy'
discord.notify(
header: 'Nim-Waku deployment successful!',
cred: 'discord-waku-deployments-webhook',
)
} }
always { sh 'docker image prune -f' }
} // post
} // pipeline
def getDefaultImageTag() {
if (env.JOB_BASE_NAME) {
return env.JOB_BASE_NAME
}
switch (env.JOB_BASE_NAME) {
case 'docker-latest': return 'latest'
case 'docker-release': return 'stable'
default: return ''
}
}