Skip to content

Commit da9a86b

Browse files
committed
FABC-833 Update Jenkinsfile
This patch fixes the minor issues observed in Jenkinsfile and update the CI doc. Change-Id: I859844a2c17398675fa0a86c49a76793863975fb Signed-off-by: rameshthoomu <rameshbabu.thoomu@gmail.com>
1 parent 4efeaca commit da9a86b

File tree

4 files changed

+89
-46
lines changed

4 files changed

+89
-46
lines changed

Jenkinsfile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ timestamps { // set the timestamps on the jenkins console
2626

2727
def buildStages() {
2828
try {
29+
// LF team has to install the newer version in Jenkins global config
30+
// Send an email to helpdesk@hyperledger.org to add newer version
2931
def nodeHome = tool 'nodejs-8.14.0'
3032
def ROOTDIR = pwd()
3133
stage('Clean Environment') {
@@ -54,18 +56,18 @@ def buildStages() {
5456
env.PATH = "$GOROOT/bin:$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH"
5557
}
5658

57-
if (DOC_CHANGE > 0 && CODE_CHANGE == 0) {
58-
println "ONLY DOC BUILD"
59+
if (DOC_CHANGE > '0' && CODE_CHANGE == '0') {
60+
sh "echo -e \033[1m ONLY DOC BUILD\033[0m"
5961
docsBuild()
60-
} else if (DOC_CHANGE > 0 && CODE_CHANGE > 0) {
61-
println "CODE AND DOC BUILD"
62+
} else if (DOC_CHANGE > '0' && CODE_CHANGE > '0') {
63+
sh "echo -e \033[1m CODE AND DOC BUILD\033[0m"
6264
basicChecks()
6365
docsBuild()
6466
runTests()
6567
} else {
66-
println "CODE BUILD"
68+
sh "echo -e \033[1m CODE BUILD\033[0m"
6769
basicChecks() // basic checks
68-
println "CODE TESTS"
70+
sh "echo -e \033[1m CODE TESTS\033[0m"
6971
runTests() // e2e on merge and unit, fvt tests on parallel
7072
}
7173
} finally { // post build actions
@@ -103,7 +105,6 @@ def buildStages() {
103105
def docsBuild () {
104106
def ROOTDIR = pwd()
105107
stage("Docs Build") {
106-
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
107108
try {
108109
dir("$ROOTDIR/$BASE_DIR") {
109110
sh ''' set +x -ue
@@ -119,7 +120,6 @@ def docsBuild () {
119120
currentBuild.result = 'FAILURE'
120121
throw err
121122
}
122-
}
123123
}
124124
}
125125

@@ -155,8 +155,7 @@ def fabCar() {
155155
fabBuildLibrary.deleteContainers()
156156
// Delete unused docker images (none,dev,test-vp etc..)
157157
fabBuildLibrary.deleteUnusedImages()
158-
sh 'docker ps -a && docker images'
159-
dir("$ROOTDIR/gopath/src/github.com/hyperledger/fabric-samples/scripts/Jenkins_Scripts") {
158+
dir("$ROOTDIR/gopath/src/github.com/hyperledger/fabric-samples/scripts/ci_scripts") {
160159
sh './fabcar.sh'
161160
}
162161
} catch (err) {
@@ -182,7 +181,6 @@ def e2e_sdk_node() {
182181
fabBuildLibrary.deleteContainers()
183182
// Delete unused docker images (none,dev,test-vp etc..)
184183
fabBuildLibrary.deleteUnusedImages()
185-
sh 'docker ps -a && docker images'
186184
dir("$ROOTDIR/gopath/src/github.com/hyperledger/fabric-sdk-node") {
187185
sh '''set +x -ue
188186
npm install
@@ -322,7 +320,7 @@ def runTests() {
322320
},
323321
failFast: true ) // Stop the build flow if one job fails
324322
stage("Unstash") {
325-
if (DOC_CHANGE > 0 && CODE_CHANGE == 0) {
323+
if (DOC_CHANGE > '0' && CODE_CHANGE == '0') {
326324
// unstash not required for doc only builds
327325
println "Unstash not required"
328326
} else {
@@ -341,4 +339,4 @@ def runTests() {
341339
}
342340
}
343341
} // stage parallel
344-
} // runTests
342+
} // runTests

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Following are the steps to update cfssl package using version 1.0.8 of govendor
153153

154154
Please have a look at [Continuous Integration Process](docs/source/ca-ci.md)
155155

156+
156157
## License <a name="license"></a>
157158

158159
Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the [LICENSE](LICENSE) file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.

ci.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Set base version
1+
# Set base version from fabric branch
22
FAB_BASE_VERSION=2.0.0
3-
# Set base image version
4-
FAB_BASEIMAGE_VERSION=0.4.14
3+
# Set base image version from fabric branch
4+
FAB_BASEIMAGE_VERSION=0.4.15
55
# Pull below list of images from Hyperledger Docker Hub
66
FAB_THIRDPARTY_IMAGES_LIST=kafka zookeeper couchdb
7-
# Set related rocketChat channel name. Default: jenkins-robot
8-
CHANNEL_NAME=jenkins-robot
97
# Set compaitable go version
108
GO_VER=1.11.5
11-
# Pull below list of images from nexus3
9+
# Pull below list of images from nexus3 for e2e tests
1210
FAB_IMAGES_LIST=javaenv nodeenv
11+
# Set related rocketChat channel name. Default: jenkins-robot
12+
CHANNEL_NAME=jenkins-robot

docs/source/ca-ci.md

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
# Continuous Integration Process
22

3-
This document explains the fabric-ca Jenkins pipeline flow and FAQ's on the build process to help developer to get more familiarize with the process flow.
3+
This document explains the fabric-ca Jenkins pipeline flow and FAQ's on the build process
4+
to help developer to get more familiarize with the process flow.
45

5-
We use Jenkins as a CI tool and to manage jobs, we use [JJB](https://docs.openstack.org/infra/jenkins-job-builder). Please see the pipeline job configuration template here https://ci-docs.readthedocs.io/en/latest/source/pipeline_jobs.html#job-templates.
6+
We use Jenkins as a CI tool and to manage jobs, we use [JJB](https://docs.openstack.org/infra/jenkins-job-builder).
7+
Please see the pipeline job configuration template here https://ci-docs.readthedocs.io/en/latest/source/pipeline_jobs.html#job-templates.
68

79
## CI Pipeline flow
810

9-
- Every Gerrit patchset triggers a verify job with the Gerrit Refspec on the parent commit of the patchset and run the below tests from the `Jenkinsfile`. Note: When you are ready to merge a patchset, it's always a best practice to rebase the patchset on the latest commit.
11+
- Every Gerrit patchset triggers a verify job with the Gerrit Refspec on the parent commit
12+
of the patchset and run the below tests from the `Jenkinsfile`. Note: When you are ready
13+
to merge a patchset, it's always a best practice to rebase the patchset on the latest commit.
1014

1115
- Basic Checks (make checks)
1216
- Documentation build (tox -edocs)
1317
- Unit tests (make unit-tests)
1418
- FVT tests (make fvt-tests)
1519
- E2E tests (Only after patchset is merged)
1620

17-
All the above tests run on the Hyperledger infarstructure x86_64 build nodes. All these nodes uses the packer with pre-configured software packages. This helps us to run the tests in much faster than installing required packages everytime.
21+
All the above tests run on the Hyperledger infarstructure x86_64 build nodes. All these nodes
22+
uses the packer with pre-configured software packages. This helps us to run the tests in much
23+
faster than installing required packages everytime.
1824

19-
Below steps shows what each stage does in the Jenkins pipeline verify and merge flow. Every Gerrit patchset triggers the fabric-ca-verify-x86_64 job and runs the below tests on x86_64 platform. Before execute the below tests, it clean the environment (Deletes the left over build artifiacts) and clone the repository with the Gerrit Refspec.
25+
Below steps shows what each stage does in the Jenkins pipeline verify and merge flow.
26+
Every Gerrit patchset triggers the fabric-ca-verify-x86_64 job and runs the below tests on
27+
x86_64 platform. Before execute the below tests, it clean the environment (Deletes the left
28+
over build artifiacts) and clone the repository with the Gerrit Refspec. Based on the file
29+
extenstions, Jenkins pipeline script triggers the stages. If the patchset contains specific
30+
doc extension, it only triggers **Docs Build** Stage otherwise it triggers all stages.
2031

2132
![](images/pipeline_flow.png)
2233

@@ -29,77 +40,106 @@ Below steps shows what each stage does in the Jenkins pipeline verify and merge
2940

3041
#### Docs Build
3142

32-
- This stage gets triggered only when a patchset contains .md, .rst etc doc related file exetensions.
3343
- We run `tox -edocs` from the root directory.
34-
- Displays the output in the form of HTML Publisher on the `fabric-ca-verify-x86_64` job. Click on **Docs Output** link on the Jenkins console.
44+
- Displays the output in the form of HTML Publisher on the `fabric-ca-verify-x86_64` job.
45+
Click on **Docs Output** link on the Jenkins console.
3546

3647
#### Unit Tests
3748

38-
- We run `make unit-test` target to run the go based unit-tests and publish the coverage report on the Jenkins console. Click on **Coverage Report** link on the Jenkins console.
49+
- We run `make unit-test` target to run the go based unit-tests and publish the coverage
50+
report on the Jenkins console. Click on **Coverage Report** link on the Jenkins console
51+
to see the code coverage.
3952

4053
#### FVT Tests
4154

42-
- We run `make fvt-tests` target to fun fvt tests, which includes tests that perform end-to-end test scenarios with PosgreSQL and MySQL databases. These tests include database migration, backwards compatibility, and LDAP integration. https://github.com/hyperledger/fabric-ca/blob/master/scripts/fvt/README.md
55+
- We run `make fvt-tests` target to run fvt tests, which includes tests that performs end-to-end
56+
test scenarios with PosgreSQL and MySQL databases. These tests include database migration,
57+
backwards compatibility, and LDAP integration. https://github.com/hyperledger/fabric-ca/blob/master/scripts/fvt/README.md
4358

4459
#### E2E tests
4560

46-
- We run **e2e tests** in the **merge job** and it performs the following tests. The intention of running e2e tests as part of the merge job is to test the dependent tests of fabric-ca.
47-
- fabcar
48-
- fabric-sdk-node - We run **gulp run-end-to-end** target which executes most of the end to end tests of fabric-sdk-node which are depend on fabric-ca.
49-
- fabric-sdk-java - We run **ci_run.sh** script which is pre-baked in fabric-sdk-java repository.
61+
- We run **e2e tests** in the **merge job** and it performs the following tests. The intention
62+
of running e2e tests as part of the merge job is to test the dependent tests of fabric-ca.
63+
- fabcar
64+
- fabric-sdk-node - We run **gulp run-end-to-end** target which executes most of the end to end
65+
tests of fabric-sdk-node which are depend on fabric-ca.
66+
- fabric-sdk-java - We run **ci_run.sh** script which is pre-baked in fabric-sdk-java repository.
5067

51-
As we trigger `fabric-ca-verify-x86_64` and `fabric-ca-merge-x86_64` pipeline jobs for every gerrit patchset, we execute the tests in the below order.
68+
As we trigger `fabric-ca-verify-x86_64` and `fabric-ca-merge-x86_64` pipeline jobs for every gerrit patchset,
69+
we execute these tests in the below order.
5270

53-
After the DocsBuild is passed, Jenkins Pipeline triggers the Unit and FVT Tests parallel on two different nodes. After the tests are executed successfully it posts a Gerrit voting on the patchset. If DocsBuild fails, it send the result back to Gerrit patchset and it won't trigger further builds.
71+
After the DocsBuild stage is passed, Jenkins Pipeline triggers the Unit and FVT Tests parallel
72+
on two different nodes. After the tests are executed successfully it posts a Gerrit voting
73+
on the patchset. If DocsBuild stage fails, it send the result back to Gerrit patchset and it
74+
won't trigger further builds.
5475

5576
See below **FAQ's** for more information on the pipeline process.
5677

5778
## FAQ's
5879

5980
#### What happens on the merge job?
6081

61-
After the patchset got merged in the fabric-ca repository, it follows the above pipeline flow and executes the e2e tests in parallel to the Unit and FVT Tests.
82+
After the patchset got merged in the fabric-ca repository, it follows the above pipeline flow and
83+
executes the e2e tests in parallel to the Unit and FVT Tests.
6284

6385
**Merge Pipeline Flow**
6486

6587
```
6688
CleanEnvironment -- OutputEnvironment -- CloneRefSpec -- BasicChecks -- DocsBuild - Tests (E2E, Unit, FVT Tests)
6789
```
6890

69-
Jenkins clones the latest merged commit and runs the below steps
91+
Jenkins clones the latest merged commit and executes the below steps
7092

71-
- Build fabric, fabric-ca images & Binaries
72-
- Pull Thirdparty Images (Couchdb, zookeeper, kafka)
93+
- Build fabric, fabric-ca images & binaries
94+
- Pull Thirdparty Images from DockerHub (Couchdb, zookeeper, kafka)
7395
- Pull javaenv, nodeenv images from nexus3 (latest stable images published after successful merge job of each repo)
96+
- Tests
7497
- fabcar tests
7598
- fabric-sdk-node (npm install, gulp run-end-to-end)
7699
- fabric-sdk-java (Run ci_run.sh)
77100

78101
#### What happens if one of the build stage fails?
79102

80-
As we are running these tests in `fastFailure: true` (if any build stage fails in the parallel process, it will terminate/abort the current running tests and sends the result back to the Gerrit Patchset. This way, CI will avoid runnning tests when there is a failure in one of the parallel build stage.
103+
As we are running these tests in `fastFailure: true` (if any build stage fails in the parallel
104+
process, it will terminate/abort the current running tests and sends the result back to the
105+
Gerrit Patchset. This way, CI will avoid runnning tests when there is a failure in one of the
106+
parallel build stage.
81107

82108
It shows `aborted` on the aborted stage on pipeline staged view.
83109

84110
#### How to re-trigger failed tests?
85111

86-
With this pipeline flow, you can not re-trigger specific failed job, instead you can post comments `reverify` or `reverify-x` on the gerrit patchset to trigger the `fabric-ca-verify-x86_64` job which triggers the pipeline flow as mentioned above. Also, we provided `remerge` or `remerge-x` comment phrases to re-trigger the failed merge jobs.
112+
With this pipeline flow, you can NOT re-trigger the specific stage, but you can post comments
113+
`reverify` or `reverify-x` on the gerrit patchset to trigger the `fabric-ca-verify-x86_64`
114+
job which triggers the pipeline flow as mentioned above. Also, we provided `remerge` or `remerge-x`
115+
comment phrases to re-trigger the failed merge jobs.
87116

88117
#### Where should I see the output of the stages?
89118

90-
Piepline supports two views (stages and blueocean). Staged views shows on the Jenkins job main page and it shows each stage in order and the status. For better view, we suggest you to access BlueOcean plugin. Click on the JOB Number and click on the **Open Blue Ocean** link that shows the build stages in pipeline view.
119+
Piepline supports two views (staged and blueocean). **Staged views** shows on the Jenkins job main
120+
page and it shows each stage in order and the status. For better view, we suggest you to access
121+
BlueOcean plugin. Click on the JOB Number and click on the **Open Blue Ocean** link that shows
122+
the build stages in pipeline view.
91123

92124
#### How to add more stages to this pipeline flow?
93125

94-
We use scripted pipeline syntax with groovy and shell scripts. Also, we use global shared library scripts which are placed in https://github.com/hyperledger/ci-management/tree/master/vars. Try to leverage these common functions in your code. All you have to do is, undestand the pipeline flow of the tests and conditions, add more stages as mentioned in the existing Jenkinsfile.
126+
We use scripted pipeline syntax with groovy and shell scripts. Also, we use global shared library
127+
scripts which are placed in https://github.com/hyperledger/ci-management/tree/master/vars.
128+
Try to leverage these common functions in your code. All you have to do is, undestand the pipeline
129+
flow of the tests and conditions, add more stages as mentioned in the existing Jenkinsfile.
95130

96131
#### How will I get build failure notifications?
97132

98-
On every merge failure, we send build failure email notications to the submitter of the patchset and send build details to the Rocket Chat **jenkins-robot** channel. Check the result here https://chat.hyperledger.org/channel/jenkins-robot
133+
On every merge failure, we send build failure email notications to the submitter of the patchset
134+
and send build details to the Rocket Chat **jenkins-robot** channel. Check the result here
135+
https://chat.hyperledger.org/channel/jenkins-robot
99136

100137
#### What steps I have to modify when I create a new branch from master?
101138

102-
As the Jenkinsfile is completely parametrzed, you no need to modify anything in the Jenkinsfile but you may endup modifying **ci.properties** file with the appropirate Base Versions, Baseimage versions etc... in the new branch. We suggest you to modify this file immediately after you create a new branch to avoid running tests on old versions.
139+
As the Jenkinsfile is completely parametrzed, you no need to modify anything in the Jenkinsfile
140+
but you may endup modifying **ci.properties** file with the appropirate Base Versions,
141+
Baseimage versions etc... in the new branch. We suggest you to modify this file immediately
142+
after you create a new branch to avoid running tests on old versions.
103143

104144
#### What are the supported platforms
105145

@@ -112,14 +152,18 @@ We use global shared library scripts and Jenkinsfile along with the build file.
112152

113153
Global Shared Library - https://github.com/hyperledger/ci-management/tree/master/vars
114154

115-
Jenkinsfile - https://github.com/hyperledger/fabric-sdk-node/tree/master/Jenkinsfile
155+
Jenkinsfile - https://github.com/hyperledger/fabric-ca/tree/master/Jenkinsfile
116156

117157
ci.properties - https://github.com/hyperledger/fabric-ca/tree/master/ci.properties
118158
(ci.properties is the only file you have to modify with the values requried for the specific branch.)
119159

120160
Packer Scripts - https://github.com/hyperledger/ci-management/blob/master/packer/provision/docker.sh
121-
(Packer is a tool for automatically creating VM and container images, configuring them and post-processing them into standard output formats. We build Hyperledger's CI images via Packer and attach them to x86_64 build nodes. On s390x, we install manually. See the packages we install as a pre-requisite in the CI x86 build nodes.)
161+
(Packer is a tool for automatically creating VM and container images, configuring them and
162+
post-processing them into standard output formats. We build Hyperledger's CI images via Packer
163+
and attach them to x86_64 build nodes. On s390x, we install manually. See the packages we
164+
install as a pre-requisite in the CI x86 build nodes.)
122165

123166
#### How to reach out to CI team?
124167

125168
Post your questions or feedback in https://chat.hyperledger.org/channel/ci-pipeline or https://chat.hyperledger.org/channel/fabric-ci Rocket Chat channels.
169+
You can also create a JIRA task or bug in FABCI project. https://jira.hyperledger.org/projects/FABCI

0 commit comments

Comments
 (0)