2023-11-21 15:39:11 +00:00
|
|
|
#!/usr/bin/env groovy
|
2024-06-26 15:55:26 +00:00
|
|
|
library 'status-jenkins-lib@v1.8.18'
|
2021-05-06 15:14:58 +00:00
|
|
|
|
2019-03-25 10:35:38 +00:00
|
|
|
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.',
|
|
|
|
)
|
2024-03-22 11:08:57 +00:00
|
|
|
string(
|
|
|
|
name: 'RELEASE_IMAGE_TAG',
|
|
|
|
description: 'Release Docker image tag.',
|
|
|
|
defaultValue: params.RELEASE_IMAGE_TAG ?: 'deploy-test',
|
|
|
|
)
|
2019-03-25 10:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
timestamps()
|
2023-05-29 10:40:00 +00:00
|
|
|
/* Prevent Jenkins jobs from running forever */
|
|
|
|
timeout(time: 10, unit: 'MINUTES')
|
2019-03-25 10:35:38 +00:00
|
|
|
disableConcurrentBuilds()
|
|
|
|
/* Go requires a certain directory structure */
|
|
|
|
checkoutToSubdirectory('src/github.com/status-im/status-go')
|
|
|
|
/* manage how many builds we keep */
|
|
|
|
buildDiscarder(logRotator(
|
2021-03-04 17:08:34 +00:00
|
|
|
numToKeepStr: '5',
|
2019-03-25 10:35:38 +00:00
|
|
|
daysToKeepStr: '30',
|
2024-02-28 14:47:23 +00:00
|
|
|
artifactNumToKeepStr: '1',
|
2019-03-25 10:35:38 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
2023-11-23 14:55:13 +00:00
|
|
|
PLATFORM = "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"
|
2023-02-21 15:03:14 +00:00
|
|
|
/* Makefile parameters */
|
|
|
|
DOCKER_IMAGE_NAME = 'statusteam/status-go'
|
2024-04-11 08:59:37 +00:00
|
|
|
DOCKER_IMAGE_CUSTOM_TAG = "ci-build-${git.commit()}"
|
2019-03-25 10:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2021-09-28 07:52:00 +00:00
|
|
|
stage('Prep') { steps { dir(env.REPO) { script {
|
2023-02-21 15:03:14 +00:00
|
|
|
println("Output: ${env.DOCKER_IMAGE_NAME}:${env.RELEASE_IMAGE_TAG}")
|
2021-05-06 15:14:58 +00:00
|
|
|
} } } }
|
2019-03-25 10:35:38 +00:00
|
|
|
|
2021-09-28 07:52:00 +00:00
|
|
|
stage('Build') { steps { dir(env.REPO) { script {
|
2019-03-25 10:35:38 +00:00
|
|
|
sh 'make docker-image'
|
2023-02-21 15:03:14 +00:00
|
|
|
image = docker.image("${env.DOCKER_IMAGE_NAME}:${env.DOCKER_IMAGE_CUSTOM_TAG}")
|
2019-03-25 10:35:38 +00:00
|
|
|
} } } }
|
|
|
|
|
2021-09-28 07:52:00 +00:00
|
|
|
stage('Push') { steps { dir(env.REPO) { script {
|
2019-03-25 10:35:38 +00:00
|
|
|
withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
|
2024-04-11 08:59:37 +00:00
|
|
|
image.push("v${utils.getVersion()}-${git.commit()}")
|
2019-03-25 10:35:38 +00:00
|
|
|
}
|
|
|
|
} } } }
|
|
|
|
|
|
|
|
stage('Deploy') {
|
|
|
|
when { expression { params.RELEASE == true } }
|
2021-09-28 07:52:00 +00:00
|
|
|
steps { dir(env.REPO) { script {
|
2019-03-25 10:35:38 +00:00
|
|
|
withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
|
2023-02-21 15:03:14 +00:00
|
|
|
image.push(env.RELEASE_IMAGE_TAG)
|
2019-03-25 10:35:38 +00:00
|
|
|
}
|
|
|
|
} } } }
|
|
|
|
} // stages
|
|
|
|
post {
|
2021-05-06 15:14:58 +00:00
|
|
|
success { script { github.notifyPR(true) } }
|
|
|
|
failure { script { github.notifyPR(false) } }
|
2021-09-28 07:52:00 +00:00
|
|
|
always { dir(env.REPO) {
|
2019-07-29 17:28:31 +00:00
|
|
|
sh 'make clean-docker-images'
|
|
|
|
} }
|
2019-03-25 10:35:38 +00:00
|
|
|
} // post
|
|
|
|
} // pipeline
|