add Jenkinsfile for Docker image CI builds

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2021-11-08 14:45:43 +01:00 committed by Jakub
parent 96fded1b9b
commit 705c5b1689

53
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,53 @@
pipeline {
agent { label 'linux' }
parameters {
booleanParam(
name: 'DEPLOY',
description: 'Enable to deploye the Docker image.',
defaultValue: false,
)
}
options {
timestamps()
disableConcurrentBuilds()
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
))
}
environment {
IMAGE_NAME = "statusteam/telemetry"
IMAGE_DEFAULT_TAG = "${env.GIT_COMMIT.take(7)}"
IMAGE_DEPLOY_TAG = "deploy"
}
stages {
stage('Build') { steps { script {
image = docker.build(
"${env.IMAGE_NAME}:${env.IMAGE_DEFAULT_TAG}"
)
} } }
stage('Push') { steps { script {
withDockerRegistry([
credentialsId: "dockerhub-statusteam-auto"
]) {
image.push()
}
} } }
stage('Deploy') {
when { expression { params.DEPLOY } }
steps { script {
withDockerRegistry([
credentialsId: "dockerhub-statusteam-auto"
]) {
image.push(env.IMAGE_DEPLOY_TAG)
}
} } }
} // stages
} // pipeline