forked from hyperledger-archives/fabric-chaincode-evm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
110 lines (108 loc) · 4 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
#!groovy
// Copyright IBM Corp All Rights Reserved
//
// SPDX-License-Identifier: Apache-2.0
//
// Jenkinsfile get triggered when a patchset a submitted or merged
@Library("fabric-ci-lib") _ // global shared library from ci-management repository
// global shared library from ci-management repository
// https://github.com/hyperledger/ci-management/tree/master/vars (Global Shared scripts)
timestamps { // set the timestamps on the jenkins console
timeout(40) { // Build timeout set to 40 mins
node ('hyp-x') { // trigger jobs on x86_64 builds nodes
// Applicable only on x86_64 for all the versions.
// LF team has to install the newer version in Jenkins global config
// Send an email to [email protected] to add newer version
def nodeHome = tool 'nodejs-8.11.3'
env.GO_VER = "1.10.4"
env.GOPATH = "$WORKSPACE/gopath"
env.GOROOT = "/opt/go/go${GO_VER}.linux.amd64"
env.PATH = "$GOPATH/bin:$GOROOT/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:~/npm/bin:${nodeHome}/bin:$PATH"
def failure_stage = "none"
// set MARCH value to amd64, s390x, ppc64le
env.MARCH = sh(returnStdout: true, script: "uname -m | sed 's/x86_64/amd64/g'").trim()
try {
def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>)
stage('Clean Environment') {
// delete working directory
deleteDir()
// Clean build environment before start the build
fabBuildLibrary.cleanupEnv()
// Display jenkins environment details
fabBuildLibrary.envOutput()
}
stage('Checkout SCM') {
// Get changes from gerrit
fabBuildLibrary.cloneRefSpec('fabric-chaincode-evm')
// Load properties from ci.properties file
props = fabBuildLibrary.loadProperties()
}
// Run license-checks
stage("Checks") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR") {
sh '''
echo "------> Run license, spelling, linter checks"
make basic-checks
'''
}
}
catch (err) {
failure_stage = "basic-checks"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Run unit-tests (unit-tests)
stage("Unit-Tests") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR") {
sh '''
echo "------> Run unit-tests"
make unit-tests
'''
}
}
catch (err) {
failure_stage = "unit-tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Run integration tests (e2e tests)
stage("Integration-Tests") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR") {
sh '''
echo "-------> Run integration-tests"
make integration-test
'''
}
}
catch (err) {
failure_stage = "integration-test"
currentBuild.result = 'FAILURE'
throw err
}
}
}
} finally { // post build actions
// Send notifications only for merge failures
if (env.JOB_TYPE == "merge") {
if (currentBuild.result == 'FAILURE') {
// Send notification to rocketChat channel
// Send merge build failure email notifications to the submitter
sendNotifications(currentBuild.result, props["ROCKET_CHANNEL_NAME"])
}
}
// Delete workspace when build is done
cleanWs notFailBuild: true
} // end finally block
} // end node block
} // end timeout block
} // end timestamps