forked from adrianrudnik/mjml-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
71 lines (63 loc) · 1.9 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
68
69
70
71
def label = "mjml-${UUID.randomUUID().toString()}"
lock("${env.JOB_NAME}") {
podTemplate(
label: label,
yaml: """
spec:
tolerations:
- key: "onWhen"
operator: "Equal"
value: "onlyDuringBusinessDay"
effect: "NoSchedule"
""",
containers: [
containerTemplate(
name: 'jnlp',
image: 'eu.gcr.io/resources-144712/jenkins-k8s-slave:latest',
alwaysPullImage: true,
resourceRequestCpu: '450m',
resourceRequestMemory: '1000Mi',
resourceLimitMemory: '1000Mi',
args: '${computer.jnlpmac} ${computer.name}'
)
],
nodeUsageMode: 'EXCLUSIVE',
volumes: [
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')
]
)
{
node(label) {
def IMAGE_TAG = "of2m/mjml-server"
def VERSION_DOCKER = "develop.${env.BUILD_NUMBER}"
try {
checkout scm
stage("dockerhub registry login") {
withCredentials([usernamePassword(credentialsId: 'dockerhub_of2m', usernameVariable: 'CI_REGISTRY_USER', passwordVariable: 'CI_REGISTRY_PASSWORD')]) {
sh '''
if test "$CI_REGISTRY_USER" != "" -a "$CI_REGISTRY_PASSWORD" != ""
then
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
else
echo "ERROR get Credentials CI_REGISTRY_USER=$CI_REGISTRY_USER"
exit 1
fi
'''
}
}
stage('build') {
def customImage = docker.build("${IMAGE_TAG}")
customImage.push('latest')
customImage.push("${VERSION_DOCKER}")
}
}
catch (e) {
currentBuild.result = "FAILED"
throw e
}
finally {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '[email protected]', sendToIndividuals: false])
}
}
}
}