forked from d2iq-archive/dcos-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.dcos-commons-base
59 lines (50 loc) · 1.49 KB
/
Jenkinsfile.dcos-commons-base
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
#!/usr/bin/env groovy
// Configuration for https://jenkins.mesosphere.com/service/jenkins/job/dcos-commons-base%20docker%20image/
void setBuildStatus(String context) {
step([
$class: "GitHubCommitStatusSetter",
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/mesosphere/dcos-commons"]
])
}
pipeline {
agent {
label 'mesos'
}
environment {
IMAGE = "dcos-commons-base"
DOCKERFILE = "Dockerfile.base"
// Get credentials for publishing to Docker hub.
DOCKER = credentials('docker-hub-credentials')
}
stages {
stage('docker login') {
steps {
// Login to the Docker registry.
sh("docker login -u ${DOCKER_USR} -p ${DOCKER_PSW}")
}
}
stage('build') {
steps {
// Build Docker image.
sh("docker build -f ${DOCKERFILE} -t mesosphere/${IMAGE}:latest .")
}
}
stage('publish') {
// Only run this step on the master branch.
when {
branch 'master'
}
steps {
script {
sh("docker push mesosphere/${IMAGE}:latest")
}
}
}
}
post {
always {
setBuildStatus("mesosphere/${IMAGE}")
}
}
}