forked from hyperledger/fabric-sdk-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.z
97 lines (96 loc) · 4.38 KB
/
Jenkinsfile.z
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
// Copyright IBM Corp All Rights Reserved
//
// SPDX-License-Identifier: Apache-2.0
//
timeout(40) {
node('hyp-z') {
timestamps {
try {
def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>)
env.PROJECT_DIR = "gopath/src/github.com/hyperledger"
env.GOPATH = "$WORKSPACE/gopath"
env.NODE_VER = "8.11.3"
env.ARCH = "s390x"
env.PATH = "$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:~/npm/bin:/home/jenkins/.nvm/versions/node/v${NODE_VER}/bin:$PATH"
def jobname = sh(returnStdout: true, script: 'echo ${JOB_NAME} | grep "verify" && echo patchset || echo merge').trim()
def failure_stage = "none"
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
cleanWs()
try {
if (jobname == "patchset") {
println "$GERRIT_REFSPEC"
println "$GERRIT_BRANCH"
checkout([
$class: 'GitSCM',
branches: [[name: '$GERRIT_REFSPEC']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT'], [$class: 'CheckoutOption', timeout: 10]],
userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '$GERRIT_REFSPEC:$GERRIT_REFSPEC', url: '$GIT_BASE']]])
} else {
// Clone fabric-sdk-node on merge
println "Clone $PROJECT repository"
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/$GERRIT_BRANCH']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT']],
userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '+refs/heads/$GERRIT_BRANCH:refs/remotes/origin/$GERRIT_BRANCH', url: '$GIT_BASE']]])
}
dir("${ROOTDIR}/$PROJECT_DIR/$PROJECT") {
sh '''
# Print last two commit details
echo
git log -n2 --pretty=oneline --abbrev-commit
echo
'''
}
}
catch (err) {
failure_stage = "Fetch patchset"
throw err
}
}
// clean environment and get env data
stage("Clean Environment - Get Env Info") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --clean_Environment --env_Info'
}
}
catch (err) {
failure_stage = "Clean Environment - Get Env Info"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Run gulp tests (headless and IntegrationTests)
stage(" Run Headless & Integration Tests") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
// Get the testFabricVersion and thirdpartyVersion from package.json
// and Pull the DockerImages from dockerhub and run the Integration Tests
sh './CI_Script.sh --sdk_E2e_Tests'
}
}
catch (err) {
failure_stage = "sdk_E2e_Tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
} finally { // Code for coverage report
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log'
// Send build notifications only on Merge failure to Jenkins-robot RocketChat Channel
if (env.JOB_NAME == "fabric-sdk-node-merge-s390x") {
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
rocketSend message: "Build Notification - STATUS: *${currentBuild.result}* - BRANCH: *${env.GERRIT_BRANCH}* - PROJECT: *${env.PROJECT}* - BUILD_URL: (<${env.BUILD_URL}|Open>)"
}
}
} // finally block end here
} // timestamps block end here
} // node block end here
} // time block end here