forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-build.groovy
71 lines (65 loc) · 2.84 KB
/
release-build.groovy
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
#!/usr/bin/env groovy
def doReleaseBuild() {
def parallelism = params.PARALLELISM
// params are always null unless job is started
// this is the case for the FIRST build only.
// So just set this to same value as default.
// This is a known bug. See https://issues.jenkins-ci.org/browse/JENKINS-41929
if (parallelism == null) {
parallelism = 4
}
if ("arm7" in env.NODE_NAME) {
parallelism = 1
}
def platform = sh(script: 'uname -m', returnStdout: true).trim()
sh "curl -L -o /tmp/${env.GIT_COMMIT}/Dockerfile --create-dirs https://raw.githubusercontent.com/hyperledger/iroha/${env.GIT_COMMIT}/docker/develop/${platform}/Dockerfile"
// pull docker image for building release package of Iroha
// speeds up consequent image builds as we simply tag them
sh "docker pull ${DOCKER_BASE_IMAGE_DEVELOP}"
iC = docker.build("hyperledger/iroha:${GIT_COMMIT}-${BUILD_NUMBER}", "--build-arg PARALLELISM=${parallelism} -f /tmp/${env.GIT_COMMIT}/Dockerfile /tmp/${env.GIT_COMMIT}")
sh "mkdir /tmp/${env.GIT_COMMIT}-${BUILD_NUMBER} || true"
iC.inside(""
+ " -v /tmp/${GIT_COMMIT}-${BUILD_NUMBER}:/tmp/${GIT_COMMIT}"
+ " -v /var/jenkins/ccache:${CCACHE_RELEASE_DIR}") {
def scmVars = checkout scm
env.IROHA_VERSION = "0x${scmVars.GIT_COMMIT}"
env.IROHA_HOME = "/opt/iroha"
env.IROHA_BUILD = "${env.IROHA_HOME}/build"
sh """
ccache --version
ccache --show-stats
ccache --zero-stats
ccache --max-size=5G
"""
sh """
cmake \
-H. \
-Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DIROHA_VERSION=${env.IROHA_VERSION} \
-DPACKAGE_DEB=ON \
-DPACKAGE_TGZ=ON \
-DCOVERAGE=OFF \
-DTESTING=OFF
"""
sh "cmake --build build --target package -- -j${parallelism}"
sh "ccache --show-stats"
// copy build package to the volume
sh "cp ./build/iroha-*.deb /tmp/${GIT_COMMIT}/iroha.deb"
}
sh "curl -L -o /tmp/${env.GIT_COMMIT}/Dockerfile --create-dirs https://raw.githubusercontent.com/hyperledger/iroha/${env.GIT_COMMIT}/docker/release/${platform}/Dockerfile"
sh "curl -L -o /tmp/${env.GIT_COMMIT}/entrypoint.sh https://raw.githubusercontent.com/hyperledger/iroha/${env.GIT_COMMIT}/docker/release/${platform}/entrypoint.sh"
sh "cp /tmp/${GIT_COMMIT}-${BUILD_NUMBER}/iroha.deb /tmp/${env.GIT_COMMIT}"
sh "chmod +x /tmp/${env.GIT_COMMIT}/entrypoint.sh"
iCRelease = docker.build("hyperledger/iroha:${GIT_COMMIT}-${BUILD_NUMBER}-release", "--no-cache -f /tmp/${env.GIT_COMMIT}/Dockerfile /tmp/${env.GIT_COMMIT}")
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
if (env.BRANCH_NAME == 'develop') {
iCRelease.push("${platform}-develop-latest")
}
else if (env.BRANCH_NAME == 'master') {
iCRelease.push("${platform}-latest")
}
}
sh "docker rmi ${iCRelease.id}"
}
return this