forked from Return-To-The-Roots/s25client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
180 lines (149 loc) · 6.82 KB
/
Jenkinsfile
File metadata and controls
180 lines (149 loc) · 6.82 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/groovy
///////////////////////////////////////////////////////////////////////////////
def transformIntoStep(arch, wspwd) {
return {
timeout(120) {
node('master') {
ansiColor('xterm') {
ws(wspwd + "/ws/" + arch) {
echo "Build ${arch} in " + pwd()
if( isUnix() ) {
sh 'chmod -R u+w .git || true' // fixes unstash overwrite bug ... #JENKINS-33126
}
unstash 'source'
sh """set -x
BARCH=--arch=c.${arch}
if [ "\$(uname -s | tr "[:upper:]" "[:lower:]").\$(uname -m)" = "${arch}" ] ; then
BARCH=
fi
PARAMS=
VOLUMES="-v /srv/apache2/siedler25.org/nightly:/www \
-v /srv/backup/www/s25client:/archive \
"
COMMANDS=
if [[ "${env.BRANCH_NAME}" == PR-* ]] ; then
VOLUMES=""
elif [ "${env.BRANCH_NAME}" == "master" ] ; then
PARAMS=create_nightly
elif [ "${env.BRANCH_NAME}" == "stable" ] ; then
PARAMS=create_stable
COMMANDS='&& rm -f build_version_defines.h.force && make updateversion && sed -i -e "s/WINDOW_VERSION \\\"[0-9]*\\\"/WINDOW_VERSION \\\"\$(cat ../.stable-version)\\\"/g" build_version_defines.h && touch build_version_defines.h.force && cat build_version_defines.h'
fi
docker run --rm -u jenkins -v \$(pwd):/workdir \
-v ~/.ssh:/home/jenkins/.ssh \
-v ~/.ccache:/workdir/.ccache \
\$VOLUMES \
--name "${env.BUILD_TAG}-${arch}" \
git.ra-doersch.de:5005/rttr/docker-precise:master -c \
"cd build && ./cmake.sh --prefix=. \$BARCH -DRTTR_ENABLE_WERROR=ON -DRTTR_USE_STATIC_BOOST=ON \$COMMANDS && make \$PARAMS"
EXIT=\$?
echo "Exiting with error code \$EXIT"
exit \$EXIT
"""
archiveArtifacts artifacts: 's25rttr*.tar.bz2,s25rttr*.zip', fingerprint: true, onlyIfSuccessful: true
}
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
catchError() {
properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '14', daysToKeepStr: '14', numToKeepStr: '180')),
disableConcurrentBuilds()
])
milestone label: 'Start'
def wspwd = "";
stage("Checkout") {
node('master') {
ansiColor('xterm') {
checkout scm
sh """set -x
git reset --hard
git submodule foreach git clean -fxd
git submodule foreach git reset --hard
git submodule update --init --force --checkout
"""
stash includes: '**, .git/', excludes: 'ws/**', name: 'source', useDefaultExcludes: false
wspwd = pwd()
}
}
}
milestone label: 'Checkout complete'
stage("Building") {
String[] archs = ["windows.i386", "windows.x86_64", "linux.i386", "linux.x86_64", "apple.universal" ]
def parallel_map = [:]
for(int i = 0; i < archs.size(); i++) {
def arch = archs[i]
echo "Adding Job ${arch}"
parallel_map["${arch}"] = transformIntoStep(arch, wspwd)
}
// mirror to launchpad step
parallel_map["mirror"] = {
node('master') {
ansiColor('xterm') {
sh """set -x
mkdir -p ws
pushd ws
if [ ! -d s25client.git ] ; then
git clone --mirror https://github.com/Return-To-The-Roots/s25client.git
(cd s25client.git && git remote set-url --push origin git+ssh://git.launchpad.net/s25rttr)
fi
cd s25client.git
git fetch -p origin
git push --mirror
"""
// todo: mirror submodules?
}
}
}
/*
parallel_map["upload-ppa"] = {
node('master') {
ansiColor('xterm') {
ws(wspwd+"/ws/upload-ppa") {
echo "Upload to PPA in "+pwd()
sh 'chmod -R u+w .git || true' // fixes unstash overwrite bug ... #JENKINS-33126
unstash 'source'
sh """set -x
if [ "${env.BRANCH_NAME}" == "master" ] || [ "${env.BRANCH_NAME}" == "latest" ] ; then
cd release
./build_deb.sh ${env.BUILD_NUMBER} || exit 1
fi
"""
}
}
}
}
*/
parallel_map.failFast = true
parallel parallel_map
}
milestone label: 'Build complete'
stage("Publishing") {
node('master') {
ansiColor('xterm') {
sh """set -x
if [ "${env.BRANCH_NAME}" == "stable" ] ; then
git tag -a "\$(cat .stable-version)-$BUILD_NUMBER" -m "Created release \$(cat .stable-version) from Jenkins build $BUILD_NUMBER"
git push git@github.com:Return-To-The-Roots/s25client.git --tags
fi
alias ssh="ssh -o ForwardX11=no"
cd release
./upload_urls.sh nightly
./upload_urls.sh stable
"""
archiveArtifacts artifacts: 'release/changelog-*.txt,release/rapidshare-*.txt', fingerprint: true, onlyIfSuccessful: true
}
}
}
milestone label: 'Publishing complete'
} // catchError()
node {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "sf-team@siedler25.org",
sendToIndividuals: true
])
}