forked from Raptor3um/raptoreum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.gitian
129 lines (114 loc) · 4.74 KB
/
Jenkinsfile.gitian
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
def targets = [
'linux',
'win',
'osx',
]
def osslTarUrl = 'http://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz'
def osslPatchUrl = 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'
def SDK_URL='https://bitcoincore.org/depends-sources/sdks'
def OSX_SDK='10.11'
def proc = 4
def mem = 2000
def repositoryUrl = "https://github.com/coinrac/coinrac.git"
def tasks = [:]
for(int i = 0; i < targets.size(); i++) {
def target = targets[i]
tasks["${target}"] = {
node {
deleteDir() // cleanup workspace
def pwd = sh(returnStdout: true, script: 'pwd').trim()
def dockerGid = sh(returnStdout: true, script: "stat -c '%g' /var/run/docker.sock").trim()
def BRANCH_NAME = sh(returnStdout: true, script: 'echo $BRANCH_NAME').trim()
def commit = BRANCH_NAME
def hasCache = false
def gitianDescriptor
stage("${target}/prepare") {
dir('coinrac') {
checkout scm
gitianDescriptor = readYaml file: "contrib/gitian-descriptors/gitian-${target}.yml"
}
dir('gitian-builder') {
git url: 'https://github.com/coinrac/gitian-builder.git'
}
sh "mkdir -p coinraccore-binaries"
if (target == "osx") {
dir('gitian-builder') {
sh 'mkdir -p inputs'
sh "curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o inputs/MacOSX${OSX_SDK}.sdk.tar.gz"
}
}
// restore cache
try {
copyArtifacts(projectName: "coinrac-coinrac-gitian-nightly/${BRANCH_NAME}", optional: true, selector: lastSuccessful(), filter: "cache-${gitianDescriptor.name}.tar.gz")
} catch (Exception e) {
}
if (fileExists("cache-${gitianDescriptor.name}.tar.gz")) {
hasCache = true
echo "Using cache from coinrac-coinrac-gitian-nightly/${BRANCH_NAME}"
} else {
try {
copyArtifacts(projectName: 'coinrac-coinrac-gitian-nightly/develop', optional: true, selector: lastSuccessful(), filter: "cache-${gitianDescriptor.name}.tar.gz");
} catch (Exception e) {
}
if (fileExists("cache-${gitianDescriptor.name}.tar.gz")) {
hasCache = true
echo "Using cache from coinrac-coinrac-gitian-nightly/develop"
}
}
}
def gitianImage
stage("${target}/builder-image") {
dir('coinrac') {
gitianImage = docker.build("coinrac-gitian:${env.BUILD_ID}", 'ci -f ci/Dockerfile.gitian-builder')
}
}
gitianImage.inside("--group-add ${dockerGid} -t -v \"/var/run/docker.sock:/var/run/docker.sock\"") {
sh "mkdir -p gitian-builder/cache"
if (hasCache) {
sh "cd gitian-builder/cache && tar xzfv ../../cache-${gitianDescriptor.name}.tar.gz"
}
stage("${target}/download") {
dir('gitian-builder') {
sh "mkdir -p inputs"
sh "cd inputs && curl -R -O ${osslPatchUrl}"
sh "cd inputs && curl -R -O ${osslTarUrl}"
sh "make -C ../coinrac/depends download SOURCES_PATH=`pwd`/cache/common"
}
}
stage("${target}/base-vm") {
dir('gitian-builder') {
sh "./bin/make-base-vm --suite bionic --arch amd64 --docker"
}
}
stage("${target}/gbuild") {
dir('gitian-builder') {
// make sure an old version is not running
sh "docker rm -fv gitian-target || true"
try {
sh """
tail -F var/install.log &
tail -F var/build.log &
USE_DOCKER=1 ./bin/gbuild -j ${proc} -m ${mem} --commit coinrac=${commit} --url coinrac=${repositoryUrl} ../coinrac/contrib/gitian-descriptors/gitian-${target}.yml
RET=\$?
# give the above tail calls enough time to print everything on failure
sleep 2s
exit \$RET
"""
} finally {
// make sure it doesn't run forever
sh "docker rm -fv gitian-target || true"
}
sh "mv build/out/coinraccore-* ../coinraccore-binaries/"
sh "mv build/out/src/coinraccore-* ../coinraccore-binaries/"
}
archiveArtifacts artifacts: 'coinraccore-binaries/*', fingerprint: true
}
// TODO remove this in a few days (only needed to prune the old compressed file from Jenkins caches)
sh "cd gitian-builder/cache && find -name ccache.tar.gz | xargs rm -f"
sh "cd gitian-builder/cache && tar czfv ../../cache-${gitianDescriptor.name}.tar.gz common ${gitianDescriptor.name}"
archiveArtifacts artifacts: "cache-${gitianDescriptor.name}.tar.gz", fingerprint: true
}
}
}
}
parallel tasks