forked from hyperledger/fabric-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
118 lines (113 loc) · 4.56 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
111
112
113
114
115
116
117
118
// Copyright IBM Corp All Rights Reserved
//
// SPDX-License-Identifier: Apache-2.0
//
// Pipeline script for fabric-samples
node ('hyp-x') { // trigger build on x86_64 node
timestamps {
try {
def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>
env.NODE_VER = "8.11.3" // NodeJs version
env.OS_VER = "amd64"
env.VERSION = sh(returnStdout: true, script: 'curl -O https://raw.githubusercontent.com/hyperledger/fabric/release-1.3/Makefile && cat Makefile | grep "PREV_VERSION =" | cut -d "=" -f2').trim()
env.VERSION = "$VERSION"
env.BASE_IMAGE_VER = sh(returnStdout: true, script: 'cat Makefile | grep BASEIMAGE_RELEASE= | cut -d "=" -f2').trim()
env.BASE_IMAGE_TAG = "${OS_VER}-${BASE_IMAGE_VER}"
env.PROJECT_DIR = "gopath/src/github.com/hyperledger"
env.GOPATH = "$WORKSPACE/gopath"
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 failure_stage = "none"
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
try {
dir("${ROOTDIR}") {
sh '''
[ -e gopath/src/github.com/hyperledger/fabric-samples ] || mkdir -p $PROJECT_DIR
cd $PROJECT_DIR
git clone git://cloud.hyperledger.org/mirror/fabric-samples && cd fabric-samples
git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
'''
}
}
catch (err) {
failure_stage = "Fetch patchset"
currentBuild.result = 'FAILURE'
throw err
}
}
// clean environment and get env data
stage("Cleanup Env") {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/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
}
}
// Pull Third Party Images (couchdb, zookeeper, kafka)
stage("Pull ThirdParty Images") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Thirdparty_Images'
}
}
catch (err) {
failure_stage = "Pull third_party docker images"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Pull Docker Images
stage("Pull Docker images") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Docker_Images'
}
}
catch (err) {
failure_stage = "Pull fabric and fabric-ca docker images"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Run byfn, eyfn tests (default, custom channel, couchdb, nodejs chaincode)
stage("Run byfn_eyfn Tests") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --byfn_eyfn_Tests'
}
}
catch (err) {
failure_stage = "byfn_eyfn_Tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
} finally {
// Archive the artifacts
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log'
// Sends notification to Rocket.Chat jenkins-robot channel
if (env.GERRIT_EVENT_TYPE == 'change-merged') {
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
rocketSend channel: 'jenkins-robot', message: "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - (<${env.BUILD_URL}|Open>)"
}
}
}
// End Try block
}
// End Node block
}