status-go/_assets/ci/Jenkinsfile.docker

80 lines
2.3 KiB
Docker
Raw Normal View History

#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.7.0'
pipeline {
agent { label 'linux' }
parameters {
string(
name: 'BRANCH',
defaultValue: 'develop',
description: 'Name of branch to build.'
)
booleanParam(
name: 'RELEASE',
defaultValue: false,
description: 'Enable to create build for release.',
)
}
options {
timestamps()
/* Prevent Jenkins jobs from running forever */
timeout(time: 10, unit: 'MINUTES')
disableConcurrentBuilds()
/* Go requires a certain directory structure */
checkoutToSubdirectory('src/github.com/status-im/status-go')
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '5',
daysToKeepStr: '30',
artifactNumToKeepStr: '1',
))
}
environment {
TARGET = "docker"
REPO = "${env.WORKSPACE}/src/github.com/status-im/status-go"
GOPATH = "${env.WORKSPACE}"
GOCACHE = "${WORKSPACE_TMP}/gocache"
PATH = "/usr/local/go/bin:${env.PATH}:${env.GOPATH}/bin"
/* Makefile parameters */
DOCKER_IMAGE_NAME = 'statusteam/status-go'
DOCKER_IMAGE_CUSTOM_TAG = "ci-build-${utils.gitCommit()}"
/* Release docker image settings. */
RELEASE_IMAGE_TAG = "deploy-test"
}
stages {
stage('Prep') { steps { dir(env.REPO) { script {
println("Output: ${env.DOCKER_IMAGE_NAME}:${env.RELEASE_IMAGE_TAG}")
} } } }
stage('Build') { steps { dir(env.REPO) { script {
sh 'make docker-image'
image = docker.image("${env.DOCKER_IMAGE_NAME}:${env.DOCKER_IMAGE_CUSTOM_TAG}")
} } } }
stage('Push') { steps { dir(env.REPO) { script {
withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
image.push("v${utils.getVersion()}-${utils.gitCommit()}")
}
} } } }
stage('Deploy') {
when { expression { params.RELEASE == true } }
steps { dir(env.REPO) { script {
withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
image.push(env.RELEASE_IMAGE_TAG)
}
} } } }
} // stages
post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
always { dir(env.REPO) {
sh 'make clean-docker-images'
} }
} // post
} // pipeline