-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
83 lines (75 loc) · 2.78 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
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env groovy
// Uses the common library
library identifier: '[email protected]', changelog: false,
retriever: modernSCM([$class: 'GitSCMSource',
remote: '[email protected]:ponderbear/pipelinelibrary.git',
credentialsId: 'jenkins-snowflurry',
traits: [gitBranchDiscovery(), gitTagDiscovery(),
[$class: 'CloneOptionTrait', extension: [depth: 1, noTags: false, reference: '', shallow: true]]]
])
node {
def projectSettings = readJSON text: '''{
"repository": {
"url": "https://github.com/Zuehlke/BiZEPS.git",
"credentials": "3bc30eda-c17e-4444-a55b-d81ee0d68981"
},
"dockerHub": {
"user": "bizeps"
},
"dockerJobs": [
{"imageName": "jenkins", "dockerfilePath": "./buildServer/jenkins/master" },
{"imageName": "awscli", "dockerfilePath": "./utils/awsCli"},
{"imageName": "certgenerator", "dockerfilePath": "./utils/certGenerator"},
{"imageName": "gcc", "dockerfilePath": "./buildTools/gcc"},
{"imageName": "mcmatools", "dockerfilePath": "./buildTools/mcmatools"},
]
}'''
def triggers = jobProperties.getJobBuildTriggers{}
properties([
pipelineTriggers(triggers),
buildDiscarder(logRotator(
artifactDaysToKeepStr: '5', artifactNumToKeepStr: '5',
numToKeepStr: '5', daysToKeepStr: '5'))
])
def branchNameParameter = "*/${buildUtils.getCurrentBuildBranch()}"
repositoryUtils.checkoutBranch {
stageName = 'Checkout'
branchName = branchNameParameter
repoUrl = "${projectSettings.repository.url}"
repoCredentials = "${projectSettings.repository.credentials}"
}
docker.withServer(env.DEFAULT_DOCKER_HOST_CONNECTION, 'default-docker-host-credentials') {
try {
stage("Build") {
def buildTasks = dockerImage.setupBuildTasks {
dockerRegistryUser = "${projectSettings.dockerHub.user}"
buildJobs = projectSettings.dockerJobs
}
for (task in buildTasks.values()) {
task.call()
}
}
docker.withRegistry(env.DEFAULT_DOCKER_REGISTRY_CONNECTION, 'default-docker-registry-credentials') {
stage("Push") {
parallel dockerImage.setupPushTasks {
dockerRegistryUser = "${projectSettings.dockerHub.user}"
buildJobs = projectSettings.dockerJobs
}
}
}
}
finally {
stage("Clean up") {
def cleanupTasks = dockerImage.setupClenupAllUnusedTask {
dockerRegistryUser = "${projectSettings.dockerHub.user}"
buildJobs = projectSettings.dockerJobs
}
for (task in cleanupTasks.values()) {
task.call()
}
// clean up workspace
deleteDir()
}
}
}
}