@@ -20,18 +20,35 @@ node ('hyp-x') { // trigger build on x86_64 node
20
20
env. PROJECT_DIR = " gopath/src/github.com/hyperledger"
21
21
env. GOPATH = " $WORKSPACE /gopath"
22
22
env. PATH = " $GOPATH /bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${ nodeHome} /bin:$PATH "
23
-
23
+ def jobname = sh( returnStdout : true , script : ' echo ${JOB_NAME} | grep -q "verify" && echo patchset || echo merge ' ) . trim()
24
24
def failure_stage = " none"
25
25
// delete working directory
26
26
deleteDir()
27
27
stage(" Fetch Patchset" ) { // fetch gerrit refspec on latest commit
28
28
try {
29
- dir(" ${ ROOTDIR} " ){
29
+ if (jobname == " patchset" ) {
30
+ println " $GERRIT_REFSPEC "
31
+ println " $GERRIT_BRANCH "
32
+ checkout([
33
+ $class : ' GitSCM' ,
34
+ branches : [[name : ' $GERRIT_REFSPEC' ]],
35
+ extensions : [[$class : ' RelativeTargetDirectory' , relativeTargetDir : ' gopath/src/github.com/hyperledger/$PROJECT' ], [$class : ' CheckoutOption' , timeout : 10 ]],
36
+ userRemoteConfigs : [[credentialsId : ' hyperledger-jobbuilder' , name : ' origin' , refspec : ' $GERRIT_REFSPEC:$GERRIT_REFSPEC' , url : ' $GIT_BASE' ]]])
37
+ } else {
38
+ // Clone fabric-samples on merge
39
+ println " Clone $PROJECT repository"
40
+ checkout([
41
+ $class : ' GitSCM' ,
42
+ branches : [[name : ' refs/heads/$GERRIT_BRANCH' ]],
43
+ extensions : [[$class : ' RelativeTargetDirectory' , relativeTargetDir : ' gopath/src/github.com/hyperledger/$PROJECT' ]],
44
+ userRemoteConfigs : [[credentialsId : ' hyperledger-jobbuilder' , name : ' origin' , refspec : ' +refs/heads/$GERRIT_BRANCH:refs/remotes/origin/$GERRIT_BRANCH' , url : ' $GIT_BASE' ]]])
45
+ }
46
+ dir(" ${ ROOTDIR} /$PROJECT_DIR /$PROJECT " ) {
30
47
sh '''
31
- [ -e gopath/src/github.com/hyperledger/fabric-samples ] || mkdir -p $PROJECT_DIR
32
- cd $PROJECT_DIR
33
- git clone git://cloud.hyperledger.org/mirror/fabric-samples && cd fabric-samples
34
- git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
48
+ # Print last two commit details
49
+ echo
50
+ git log -n2 --pretty=oneline --abbrev-commit
51
+ echo
35
52
'''
36
53
}
37
54
}
@@ -40,7 +57,7 @@ node ('hyp-x') { // trigger build on x86_64 node
40
57
currentBuild. result = ' FAILURE'
41
58
throw err
42
59
}
43
- }
60
+ }
44
61
// clean environment and get env data
45
62
stage(" Clean Environment - Get Env Info" ) {
46
63
try {
@@ -56,7 +73,7 @@ node ('hyp-x') { // trigger build on x86_64 node
56
73
}
57
74
58
75
// Pull Third_party Images
59
- stage(" Pull third_party images " ) {
76
+ stage(" Pull third_party Images " ) {
60
77
// making the output color coded
61
78
wrap([$class : ' AnsiColorBuildWrapper' , ' colorMapName' : ' xterm' ]) {
62
79
try {
@@ -73,7 +90,7 @@ node ('hyp-x') { // trigger build on x86_64 node
73
90
}
74
91
75
92
// Pull Fabric, fabric-ca Images
76
- stage(" Pull Docker images " ) {
93
+ stage(" Pull Docker Images " ) {
77
94
// making the output color coded
78
95
wrap([$class : ' AnsiColorBuildWrapper' , ' colorMapName' : ' xterm' ]) {
79
96
try {
@@ -126,13 +143,13 @@ node ('hyp-x') { // trigger build on x86_64 node
126
143
// Archive the artifacts
127
144
archiveArtifacts allowEmptyArchive : true , artifacts : ' **/*.log'
128
145
// Sends notification to Rocket.Chat jenkins-robot channel
129
- if (env. JOB_NAME == " fabric-samples-merge-byfn " ) {
146
+ if (env. JOB_NAME == " fabric-samples-merge-job " ) {
130
147
if (currentBuild. result == ' FAILURE' ) { // Other values: SUCCESS, UNSTABLE
131
148
rocketSend message : " Build Notification - STATUS: *${ currentBuild.result} * - BRANCH: *${ env.GERRIT_BRANCH} * - PROJECT: *${ env.PROJECT} * - (<${ env.BUILD_URL} |Open>)"
132
149
}
133
150
}
134
151
}
135
- // End Try block
152
+ // End Timestamps block
136
153
}
137
154
// End Node block
138
155
}
0 commit comments