-
Notifications
You must be signed in to change notification settings - Fork 77
/
Jenkinsfile
152 lines (137 loc) · 5.64 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright (C) 2005 - 2021 Settlers Freaks <sf-team at siedler25.org>
//
// SPDX-License-Identifier: GPL-2.0-or-later
dockerRegistry = "registry.mytrap.de/"
dockerCredentials = "gitlab-Flow86"
dockerImages = [
"windows.i686" : "rttr/cross-compiler/mingw/mingw-w64-docker:master",
"windows.x86_64" : "rttr/cross-compiler/mingw/mingw-w64-docker:master",
"linux.x86_64" : "rttr/cross-compiler/linux/linux-amd64-docker:master",
"apple.x86_64" : "rttr/cross-compiler/apple/apple-docker:master"
]
def transformIntoStep(architecture, dockerImage, buildScript) {
return {
timeout(120) {
def wspwd = pwd()
dir("build-$architecture") {
sh 'touch .git-keep'
withDockerRegistry( registry: [credentialsId: dockerCredentials, url: 'https://'+dockerRegistry ] ) {
withDockerContainer(
image: dockerRegistry+dockerImage,
args: " \
-v $HOME/.ccache:/.ccache \
-v $wspwd/source:/source:ro \
-v $wspwd/result:/result \
") {
def script = buildScript.replace("%architecture%", architecture)
sh script
}
}
}
}
}
}
pipeline {
agent {
label "docker"
}
parameters {
choice(name: 'DEPLOY_TO', choices: [ "none", "nightly", "stable"], description: 'deploy to this after build (none = disable deployment)')
booleanParam(name: 'FORCE_DEPLOY', defaultValue: false, description: 'deploy even if nothing has been changed (false = only deploy on changes)')
}
options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '14', daysToKeepStr: '14', numToKeepStr: '180'))
disableConcurrentBuilds()
skipDefaultCheckout(true)
}
environment {
DEBIAN_FRONTEND = 'noninteractive'
}
stages {
stage('checkout') {
steps {
dir('source') {
checkout scm: [
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: scm.extensions + [
[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true, reference: '', trackingSubmodules: false],
[$class: 'AuthorInChangelog'],
[$class: 'CleanCheckout']
],
submoduleCfg: [],
userRemoteConfigs: scm.userRemoteConfigs
]
sh """
git status
git submodule foreach git status
git restore-mtime -c || echo "Unable to restore file modification time" >&2
git submodule foreach "git restore-mtime -c || echo "Unable to restore file modification time" >&2"
"""
}
sh 'rm -rf result'
dir('result') {
sh 'touch .git-keep'
}
}
}
stage('changelog') {
steps {
script {
def changelogScript = readTrusted("tools/ci/jenkins/changelog.sh")
sh changelogScript
}
}
}
stage('build') {
steps {
script {
def parallel_map = [:]
def buildScript = readTrusted("tools/ci/jenkins/build.sh")
buildScript = buildScript.replace("%deploy_to%", params.DEPLOY_TO)
buildScript = buildScript.replace("%force_deploy%", params.FORCE_DEPLOY.toString())
dockerImages.each { architecture, image ->
echo "Adding Job ${architecture} (${image})"
parallel_map["${architecture}"] = transformIntoStep(architecture, image, buildScript)
}
// todo: mirror launchpad
parallel_map.failFast = true
parallel parallel_map
}
}
}
stage('deploy') {
when {
expression { return params.DEPLOY_TO != "none" }
}
steps {
script {
def prepareDeployScript = readTrusted("tools/ci/jenkins/prepare-deploy.sh")
prepareDeployScript = prepareDeployScript.replace("%deploy_to%", params.DEPLOY_TO)
prepareDeployScript = prepareDeployScript.replace("%force_deploy%", params.FORCE_DEPLOY.toString())
sh prepareDeployScript
def deployScript = readTrusted("tools/ci/jenkins/deploy.sh")
deployScript = deployScript.replace("%deploy_to%", params.DEPLOY_TO)
deployScript = deployScript.replace("%force_deploy%", params.FORCE_DEPLOY.toString())
sh deployScript
}
}
}
}
post {
success {
dir('result') {
archiveArtifacts artifacts: '*.tar.bz2,*.zip,*.txt', fingerprint: true
}
}
failure {
mail to: '[email protected]',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Pipeline failed: ${env.BUILD_URL}"
}
cleanup {
sh 'rm -rf result'
}
}
}