-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
42 lines (37 loc) · 1.12 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
def gitCommit() {
sh "git rev-parse HEAD > GIT_COMMIT"
def gitCommit = readFile('GIT_COMMIT').trim()
sh "rm -f GIT_COMMIT"
return gitCommit
}
node {
// Checkout source code from Git
stage 'Checkout'
checkout scm
// Build Docker image
stage 'Build'
sh "docker build -t pp023549/mesospherevny:${gitCommit()} ."
// Log in and push image to GitLab
stage 'Publish'
withCredentials(
[[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'dockerhub-mesosphere',
passwordVariable: 'DOCKERHUB_PASSWORD',
usernameVariable: 'DOCKERHUB_USERNAME'
]]
) {
sh "docker login -u '${env.DOCKERHUB_USERNAME}' -p '${env.DOCKERHUB_PASSWORD}' -e [email protected]"
sh "docker push pp023549/mesospherevny:${gitCommit()}"
}
// Deploy
stage 'Deploy'
marathon(
url: 'http://marathon.mesos:8080',
forceUpdate: false,
credentialsId: 'dcos-token',
filename: 'marathon.json',
id: 'nginx-mesosphere',
docker: "pp023549/mesospherevny:${gitCommit()}".toString()
)
}