dash/Jenkinsfile.gitian
2018-10-25 09:16:13 +02:00

128 lines
4.5 KiB
Plaintext

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/dashpay/dash.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('dash') {
checkout scm
gitianDescriptor = readYaml file: "contrib/gitian-descriptors/gitian-${target}.yml"
}
dir('gitian-builder') {
git url: 'https://github.com/dashpay/gitian-builder.git'
}
sh "mkdir -p dashcore-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: "dashpay-dash-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 dashpay-dash-gitian-nightly/${BRANCH_NAME}"
} else {
try {
copyArtifacts(projectName: 'dashpay-dash-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 dashpay-dash-gitian-nightly/develop"
}
}
}
def gitianImage
stage("${target}/builder-image") {
dir('dash') {
gitianImage = docker.build("dash-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 ../dash/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 dash=${commit} --url dash=${repositoryUrl} ../dash/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/dashcore-* ../dashcore-binaries/"
sh "mv build/out/src/dashcore-* ../dashcore-binaries/"
}
archiveArtifacts artifacts: 'dashcore-binaries/*', fingerprint: true
}
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