This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
/
Jenkinsfile.dcos-commons-base_
75 lines (66 loc) · 2.33 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env groovy
// Configuration for https://jenkins.mesosphere.com/service/jenkins/job/dcos-commons-base%20docker%20image/
// This file's name ends with an underscore due to DCOS-57609
void setBuildStatus(String context, String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/mesosphere/dcos-commons"],
statusResultSource: [
$class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]]
]
])
}
pipeline {
agent {
label 'dcos-commons'
}
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 {
// Prevent indefinite hangs: DCOS-57576
timeout(activity: true, time: 1, unit: 'HOURS') {
// Build Docker image.
sh("docker build --squash -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 {
success {
setBuildStatus("mesosphere/${IMAGE}", "Docker image build/push succeeded", "SUCCESS");
}
failure {
setBuildStatus("mesosphere/${IMAGE}", "Docker image build/push failed", "FAILURE");
}
aborted {
setBuildStatus("mesosphere/${IMAGE}", "Docker image build/push aborted", "ERROR");
}
unstable {
setBuildStatus("mesosphere/${IMAGE}", "Docker image build/push unstable", "ERROR");
}
}
}