2023-10-17 15:12:25 +00:00
|
|
|
pipeline {
|
|
|
|
agent { label 'linux' }
|
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(
|
|
|
|
name: 'IMAGE_TAG',
|
|
|
|
defaultValue: params.IMAGE_TAG ?: '',
|
|
|
|
description: 'Optional Docker image tag to push.'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
/* manage how many builds we keep */
|
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '20',
|
|
|
|
daysToKeepStr: '30',
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
2023-12-06 14:50:47 +00:00
|
|
|
IMAGE_NAME = 'statusteam/free-technology'
|
|
|
|
NEXT_PUBLIC_SITE_URL = "https://${env.JOB_BASE_NAME}"
|
2023-10-17 15:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Build') {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
withCredentials([
|
|
|
|
string(
|
2023-12-06 14:50:47 +00:00
|
|
|
credentialsId: 'free-technology-github-token',
|
|
|
|
variable: 'NEXT_GITHUB_PERSONAL_ACCESS_TOKEN'
|
2023-10-17 15:12:25 +00:00
|
|
|
),
|
|
|
|
]) {
|
|
|
|
image = docker.build(
|
|
|
|
"${IMAGE_NAME}:${GIT_COMMIT.take(8)}",
|
2023-12-06 14:50:47 +00:00
|
|
|
["--build-arg='NEXT_GITHUB_PERSONAL_ACCESS_TOKEN=${NEXT_GITHUB_PERSONAL_ACCESS_TOKEN}'",
|
2023-10-17 15:12:25 +00:00
|
|
|
"."].join(' ')
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Push') {
|
|
|
|
steps { script {
|
2023-12-06 14:50:47 +00:00
|
|
|
withDockerRegistry([credentialsId: 'dockerhub-statusteam-auto', url: '']) {
|
2023-10-17 15:12:25 +00:00
|
|
|
image.push()
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Deploy') {
|
|
|
|
when { expression { params.IMAGE_TAG != '' } }
|
|
|
|
steps { script {
|
2023-12-06 14:50:47 +00:00
|
|
|
withDockerRegistry([credentialsId: 'dockerhub-statusteam-auto', url: '']) {
|
2023-10-17 15:12:25 +00:00
|
|
|
image.push(params.IMAGE_TAG)
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
cleanup { cleanWs() }
|
|
|
|
}
|
|
|
|
}
|