nwaku/ci/Jenkinsfile.release

91 lines
2.6 KiB
Plaintext

pipeline {
agent { label 'linux' }
options {
timestamps()
/* Prevent Jenkins jobs from running forever */
timeout(time: 20, unit: 'MINUTES')
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
))
}
/* WARNING: Two more parameters can be defined.
* See 'environment' section. */
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: params.IMAGE_TAG ?: 'deploy-wakuv2-test',
)
string(
name: 'IMAGE_NAME',
description: 'Name of Docker image to push.',
defaultValue: params.IMAGE_NAME ?: 'statusteam/nim-waku',
)
string(
name: 'NIMFLAGS',
description: 'Flags for Nim compilation.',
defaultValue: params.NIMFLAGS ?: [
'--colors:off',
'-d:disableMarchNative',
'-d:chronicles_colors:none',
'-d:insecure',
].join(' ')
)
}
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}' ."
)
} }
}
stage('Push') {
steps { script {
withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
image.push()
image.push(env.IMAGE_TAG)
}
} }
}
} // stages
post {
success { script {
withCredentials([
string(
credentialsId: 'discord-waku-deployments-webhook',
variable: 'DISCORD_WEBHOOK'
),
]) {
discordSend(
title: "${env.JOB_NAME}#${env.BUILD_NUMBER}",
description: """
Nim-Waku deployment successful!
Image: [`${IMAGE_NAME}:${IMAGE_TAG}`](https://hub.docker.com/r/${IMAGE_NAME}/tags?page=1&name=${IMAGE_TAG})
Branch: [`${GIT_BRANCH.minus("origin/")}`](https://github.com/status-im/nwaku/commits/${GIT_BRANCH.minus("origin/")})
Commit: [`${GIT_COMMIT.take(8)}`](https://github.com/status-im/nwaku/commit/${GIT_COMMIT.take(8)})
""",
link: env.BUILD_URL,
result: currentBuild.currentResult,
webhookURL: env.DISCORD_WEBHOOK
)
}
} }
always { sh 'docker image prune -f' }
} // post
} // pipeline