-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
67 lines (60 loc) · 1.47 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 {
IMAGE_NAME = 'statusteam/free-technology'
NEXT_PUBLIC_SITE_URL = "https://${env.JOB_BASE_NAME}"
}
stages {
stage('Build') {
steps {
script {
withCredentials([
string(
credentialsId: 'free-technology-github-token',
variable: 'NEXT_GITHUB_PERSONAL_ACCESS_TOKEN'
),
]) {
image = docker.build(
"${IMAGE_NAME}:${GIT_COMMIT.take(8)}",
["--build-arg='NEXT_GITHUB_PERSONAL_ACCESS_TOKEN=${NEXT_GITHUB_PERSONAL_ACCESS_TOKEN}'",
"."].join(' ')
)
}
}
}
}
stage('Push') {
steps { script {
withDockerRegistry([credentialsId: 'dockerhub-statusteam-auto', url: '']) {
image.push()
}
} }
}
stage('Deploy') {
when { expression { params.IMAGE_TAG != '' } }
steps { script {
withDockerRegistry([credentialsId: 'dockerhub-statusteam-auto', url: '']) {
image.push(params.IMAGE_TAG)
}
} }
}
}
post {
cleanup { cleanWs() }
}
}