mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
FABCI-284 Update CI Pipeline script
This patch updates CI pipeline scripts which utilizes global shared library reusable functions. It also creates ci.properties file with all the parameters required to test the fabric-samples patch. Change-Id: I9ed97c8dd0c07a3677042dbda034043e8a19a0f1 Signed-off-by: rameshthoomu <rameshbabu.thoomu@gmail.com>
This commit is contained in:
parent
c24abf9c01
commit
1bd1c2f355
11 changed files with 422 additions and 148 deletions
296
Jenkinsfile
vendored
296
Jenkinsfile
vendored
|
|
@ -1,155 +1,157 @@
|
||||||
|
#!groovy
|
||||||
// Copyright IBM Corp All Rights Reserved
|
// Copyright IBM Corp All Rights Reserved
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
// Pipeline script for fabric-samples
|
// Jenkinfile will get triggered on verify and merge jobs and run byfn, eyfn and fabcar
|
||||||
|
// tests.
|
||||||
|
|
||||||
node ('hyp-x') { // trigger build on x86_64 node
|
// global shared library from ci-management repository
|
||||||
timestamps {
|
// https://github.com/hyperledger/ci-management/tree/master/vars (Global Shared scripts)
|
||||||
try {
|
@Library("fabric-ci-lib") _
|
||||||
def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>
|
pipeline {
|
||||||
def nodeHome = tool 'nodejs-8.11.3'
|
agent {
|
||||||
env.ARCH = "amd64"
|
// Execute tests on x86_64 build nodes
|
||||||
env.VERSION = sh(returnStdout: true, script: 'curl -O https://raw.githubusercontent.com/hyperledger/fabric/master/Makefile && cat Makefile | grep "BASE_VERSION =" | cut -d "=" -f2').trim()
|
// Set this value from Jenkins Job Configuration
|
||||||
env.VERSION = "$VERSION" // BASE_VERSION from fabric Makefile
|
label env.NODE_ARCH
|
||||||
env.BASE_IMAGE_VER = sh(returnStdout: true, script: 'cat Makefile | grep "BASEIMAGE_RELEASE =" | cut -d "=" -f2').trim() // BASEIMAGE Version from fabric Makefile
|
}
|
||||||
env.IMAGE_TAG = "${ARCH}-${VERSION}-stable" // fabric latest stable version from nexus
|
options {
|
||||||
env.PROJECT_VERSION = "${VERSION}-stable"
|
// Using the Timestamper plugin we can add timestamps to the console log
|
||||||
env.BASE_IMAGE_TAG = "${ARCH}-${BASE_IMAGE_VER}" //fabric baseimage version
|
timestamps()
|
||||||
env.PROJECT_DIR = "gopath/src/github.com/hyperledger"
|
// Set build timeout for 60 mins
|
||||||
env.GOPATH = "$WORKSPACE/gopath"
|
timeout(time: 60, unit: 'MINUTES')
|
||||||
env.PATH = "$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH"
|
}
|
||||||
def jobname = sh(returnStdout: true, script: 'echo ${JOB_NAME} | grep -q "verify" && echo patchset || echo merge').trim()
|
environment {
|
||||||
def failure_stage = "none"
|
ROOTDIR = pwd()
|
||||||
// delete working directory
|
// Applicable only on x86_64 nodes
|
||||||
deleteDir()
|
// LF team has to install the newer version in Jenkins global config
|
||||||
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
|
// Send an email to helpdesk@hyperledger.org to add newer version
|
||||||
try {
|
nodeHome = tool 'nodejs-8.11.3'
|
||||||
if (jobname == "patchset") {
|
MARCH = sh(returnStdout: true, script: "uname -m | sed 's/x86_64/amd64/g'").trim()
|
||||||
println "$GERRIT_REFSPEC"
|
OS_NAME = sh(returnStdout: true, script: "uname -s|tr '[:upper:]' '[:lower:]'").trim()
|
||||||
println "$GERRIT_BRANCH"
|
props = "null"
|
||||||
checkout([
|
}
|
||||||
$class: 'GitSCM',
|
stages {
|
||||||
branches: [[name: '$GERRIT_REFSPEC']],
|
stage('Clean Environment') {
|
||||||
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT'], [$class: 'CheckoutOption', timeout: 10]],
|
steps {
|
||||||
userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '$GERRIT_REFSPEC:$GERRIT_REFSPEC', url: '$GIT_BASE']]])
|
script {
|
||||||
} else {
|
// delete working directory
|
||||||
// Clone fabric-samples on merge
|
deleteDir()
|
||||||
println "Clone $PROJECT repository"
|
// Clean build env before start the build
|
||||||
checkout([
|
fabBuildLibrary.cleanupEnv()
|
||||||
$class: 'GitSCM',
|
// Display jenkins environment details
|
||||||
branches: [[name: 'refs/heads/$GERRIT_BRANCH']],
|
fabBuildLibrary.envOutput()
|
||||||
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"
|
|
||||||
currentBuild.result = 'FAILURE'
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// clean environment and get env data
|
|
||||||
stage("Clean Environment - Get Env Info") {
|
|
||||||
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
|
|
||||||
stage("Pull third_party 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 Fabric, fabric-ca 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, 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run fabcar tests
|
|
||||||
stage("Run FabCar 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 --fabcar_Tests'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
failure_stage = "fabcar_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.JOB_NAME == "fabric-samples-merge-job") {
|
|
||||||
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
|
|
||||||
rocketSend message: "Build Notification - STATUS: *${currentBuild.result}* - BRANCH: *${env.GERRIT_BRANCH}* - PROJECT: *${env.PROJECT}* - (<${env.BUILD_URL}|Open>)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// End Timestamps block
|
stage('Checkout SCM') {
|
||||||
}
|
steps {
|
||||||
// End Node block
|
script {
|
||||||
}
|
// Get changes from gerrit
|
||||||
|
fabBuildLibrary.cloneRefSpec('fabric-samples')
|
||||||
|
// Load properties from ci.properties file
|
||||||
|
props = fabBuildLibrary.loadProperties()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Pull build artifacts
|
||||||
|
stage('Pull Build Artifacts') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
if(props["IMAGE_SOURCE"] == "build") {
|
||||||
|
println "BUILD ARTIFACTS"
|
||||||
|
// Set PATH
|
||||||
|
env.GOPATH = "$WORKSPACE/gopath"
|
||||||
|
env.GOROOT = "/opt/go/go" + props["GO_VER"] + ".linux." + "$MARCH"
|
||||||
|
env.PATH = "$GOPATH/bin:$GOROOT/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH"
|
||||||
|
// Clone fabric repo
|
||||||
|
fabBuildLibrary.cloneScm('fabric', '$GERRIT_BRANCH')
|
||||||
|
// Build fabric docker images and binaries
|
||||||
|
fabBuildLibrary.fabBuildImages('fabric', 'docker dist')
|
||||||
|
// Clone fabric-ca repo
|
||||||
|
fabBuildLibrary.cloneScm('fabric-ca', '$GERRIT_BRANCH')
|
||||||
|
// Build fabric docker images and binaries
|
||||||
|
fabBuildLibrary.fabBuildImages('fabric-ca', 'docker dist')
|
||||||
|
// Copy binaries to fabric-samples dir
|
||||||
|
sh 'cp -r $ROOTDIR/gopath/src/github.com/hyperledger/fabric/release/$OS_NAME-$MARCH/bin $ROOTDIR/$BASE_DIR/'
|
||||||
|
// Pull Thirdparty Docker Images from hyperledger DockerHub
|
||||||
|
fabBuildLibrary.pullThirdPartyImages(props["FAB_BASEIMAGE_VERSION"], props["FAB_THIRDPARTY_IMAGES_LIST"])
|
||||||
|
} else {
|
||||||
|
dir("$ROOTDIR/$BASE_DIR") {
|
||||||
|
// Set PATH
|
||||||
|
env.GOPATH = "$WORKSPACE/gopath"
|
||||||
|
env.GOROOT = "/opt/go/go" + props["GO_VER"] + ".linux." + "$MARCH"
|
||||||
|
env.PATH = "$GOPATH/bin:$GOROOT/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH"
|
||||||
|
// Pull Binaries with latest version from nexus2
|
||||||
|
fabBuildLibrary.pullBinaries(props["FAB_BINARY_VER"], props["FAB_BINARY_REPO"])
|
||||||
|
// Pull Docker Images from nexus3
|
||||||
|
fabBuildLibrary.pullDockerImages(props["FAB_BASE_VERSION"], props["FAB_IMAGES_LIST"])
|
||||||
|
// Pull Thirdparty Docker Images from hyperledger DockerHub
|
||||||
|
fabBuildLibrary.pullThirdPartyImages(props["FAB_BASEIMAGE_VERSION"], props["FAB_THIRDPARTY_IMAGES_LIST"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Run byfn, eyfn tests (default, custom channel, couchdb, nodejs, java chaincode)
|
||||||
|
stage('Run byfn_eyfn Tests') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// making the output color coded
|
||||||
|
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
|
||||||
|
try {
|
||||||
|
dir("$ROOTDIR/$BASE_DIR/scripts/ci_scripts") {
|
||||||
|
// Run BYFN, EYFN tests
|
||||||
|
sh './ciScript.sh --byfn_eyfn_Tests'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
failure_stage = "byfn_eyfn_Tests"
|
||||||
|
currentBuild.result = 'FAILURE'
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Run fabcar tests
|
||||||
|
stage('Run Fab Car Tests') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// making the output color coded
|
||||||
|
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
|
||||||
|
try {
|
||||||
|
dir("$ROOTDIR/$BASE_DIR/scripts/ci_scripts") {
|
||||||
|
// Run fabcar tests
|
||||||
|
sh './ciScript.sh --fabcar_Tests'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
failure_stage = "fabcar_Tests"
|
||||||
|
currentBuild.result = 'FAILURE'
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // stages
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
// Archiving the .log files and ignore if empty
|
||||||
|
archiveArtifacts artifacts: '**/*.log', allowEmptyArchive: true
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
script {
|
||||||
|
if (env.JOB_TYPE == 'merge') {
|
||||||
|
// Send rocketChat notification to channel
|
||||||
|
// Send merge build failure email notifications to the submitter
|
||||||
|
sendNotifications(currentBuild.result, props["CHANNEL_NAME"])
|
||||||
|
// Delete workspace when build is done
|
||||||
|
cleanWs notFailBuild: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // post
|
||||||
|
} // pipeline
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ are 1.4.0, 1.4.0 and 0.4.14 respectively.
|
||||||
./scripts/bootstrap.sh [version] [ca version] [thirdparty_version]
|
./scripts/bootstrap.sh [version] [ca version] [thirdparty_version]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Continuous Integration
|
||||||
|
|
||||||
|
Please have a look at [Continuous Integration Process](docs/fabric-samples-ci.md)
|
||||||
|
|
||||||
## License <a name="license"></a>
|
## License <a name="license"></a>
|
||||||
|
|
||||||
Hyperledger Project source code files are made available under the Apache
|
Hyperledger Project source code files are made available under the Apache
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export MSYS_NO_PATHCONV=1
|
||||||
docker-compose -f docker-compose.yml down
|
docker-compose -f docker-compose.yml down
|
||||||
|
|
||||||
docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
|
docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
|
||||||
|
docker ps -a
|
||||||
|
|
||||||
# wait for Hyperledger Fabric to start
|
# wait for Hyperledger Fabric to start
|
||||||
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
|
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
|
||||||
|
|
|
||||||
21
ci.properties
Normal file
21
ci.properties
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Set "nexus" if you would like to pull images from nexus3
|
||||||
|
# Set "build" if you would like build fabric, fabric-ca on latest commits
|
||||||
|
IMAGE_SORUCE=nexus
|
||||||
|
# set only "javaenv" image if you set IMAGE_SOURCE to "build"
|
||||||
|
# Pull below list of images from nexus3 if IMAGE_SOURCE is set to "nexus" or "build"
|
||||||
|
FAB_IMAGES_LIST=ca peer orderer ccenv tools baseos nodeenv javaenv
|
||||||
|
# Set fabric if you would like pull only fabric binaries
|
||||||
|
FAB_BINARY_REPO=fabric fabric-ca
|
||||||
|
# Pull below list of images from Hyperledger DockerHub
|
||||||
|
FAB_THIRDPARTY_IMAGES_LIST=kafka zookeeper couchdb
|
||||||
|
# Pull latest binaries of latest commit of release-1.4 from nexus snapshots
|
||||||
|
# Applicable only when set IMAGE_SOURCE to "nexus"
|
||||||
|
FAB_BINARY_VER=latest
|
||||||
|
# Set base version from fabric branch
|
||||||
|
FAB_BASE_VERSION=2.0.0
|
||||||
|
# Set base image version from fabric branch
|
||||||
|
FAB_BASEIMAGE_VERSION=0.4.15
|
||||||
|
# Set related rocketChat channel name. Default: jenkins-robot
|
||||||
|
CHANNEL_NAME=jenkins-robot
|
||||||
|
# Set compaitable go version
|
||||||
|
GO_VER=1.11.5
|
||||||
109
docs/fabric-samples-ci.md
Normal file
109
docs/fabric-samples-ci.md
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
# Continuous Integration Process
|
||||||
|
|
||||||
|
This document explains the fabric-samples Jenkins pipeline flow and FAQ's on the build
|
||||||
|
process to help developer to get more familiarize with the process flow.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## CI Pipeline flow
|
||||||
|
|
||||||
|
- Every Gerrit patchset triggers a verify job with the Gerrit Refspec on the parent commit
|
||||||
|
of the patchset and runs the below tests from the `Jenkinsfile`. Note: when you are ready
|
||||||
|
to merge the patchset, it's always a best practice to rebase the patchset on the latest commit.
|
||||||
|
|
||||||
|
All the below tests runs 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.
|
||||||
|
|
||||||
|
Below steps shows what each stage does in the Jenkins pipeline verify and merge flow.
|
||||||
|
Before execute the below tests, it clean the environment (Deletes the left over build artifiacts)
|
||||||
|
and clone the repository with the Gerrit Refspec.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Based on the value provided to **IMAGE_SOURCE** in ci.properties file, Jenkinsfile execute the
|
||||||
|
steps. If the IMAGE_SOURCE is set to "build", Jenkins clones the latest commits of fabric
|
||||||
|
and fabric-ca and builds the docker images and binaries. If you specify IMAGE_SOURCE as "nexus",
|
||||||
|
it always pulls the latest fabric and fabric-ca images published from nightly job which triggers
|
||||||
|
everyday at 8:00 PM EST.
|
||||||
|
|
||||||
|
Also, it pulls the "javaenv" and "nodeenv" images from the latest published images from nexus3.
|
||||||
|
NOTE: nodeenv image is available only in master branch.
|
||||||
|
|
||||||
|
Once the artifacts stage is ready, Jenkins executes the below tests
|
||||||
|
|
||||||
|
- byfn & eyfn tests
|
||||||
|
- on default channel
|
||||||
|
- Custom channel with couchdb
|
||||||
|
- on node chanincode
|
||||||
|
|
||||||
|
- fabcar tests
|
||||||
|
- go
|
||||||
|
- javascript
|
||||||
|
- typescript
|
||||||
|
|
||||||
|
Above pipeline flow works the same on both `fabric-samples-verify-x86_64` and `fabric-samples-merge-x86_64` pipeline jobs.
|
||||||
|
|
||||||
|
See below **FAQ's** for more information on the pipeline process.
|
||||||
|
|
||||||
|
## FAQ's
|
||||||
|
|
||||||
|
#### How to re-trigger failed tests?
|
||||||
|
|
||||||
|
You can post comments `reverify` or `reverify-x` on the gerrit patchset to trigger the `fabric-samples-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 job.
|
||||||
|
|
||||||
|
#### Where should I see the output of the stages?
|
||||||
|
|
||||||
|
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 build number and click on the **Open Blue Ocean**
|
||||||
|
link that shows the build stages in pipeline view.
|
||||||
|
|
||||||
|
#### How to add more stages to this pipeline flow?
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
#### How will I get build failure notifications?
|
||||||
|
|
||||||
|
On every merge failure, we send build failure email notications to the submitter of the
|
||||||
|
patchset and sends the build details to the Rocket Chat **jenkins-robot** channel. Check the
|
||||||
|
result here https://chat.hyperledger.org/channel/jenkins-robot
|
||||||
|
|
||||||
|
#### What steps I have to modify when I create a new branch from master?
|
||||||
|
|
||||||
|
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 older versions.
|
||||||
|
|
||||||
|
#### On what platforms these tests triggers?
|
||||||
|
|
||||||
|
- x86_64 (Run the above mentioned tests on verify and merge jobs)
|
||||||
|
- s390x (Run the above mentioned tests in daily jobs)
|
||||||
|
|
||||||
|
#### Where can I see the Build Scripts.
|
||||||
|
|
||||||
|
We use global shared library scripts and Jenkinsfile along with the build file.
|
||||||
|
|
||||||
|
Global Shared Library - https://github.com/hyperledger/ci-management/tree/master/vars
|
||||||
|
|
||||||
|
Jenkinsfile - https://github.com/hyperledger/fabric-samples/tree/master/Jenkinsfile
|
||||||
|
|
||||||
|
ci.properties - https://github.com/hyperledger/fabric-samples/tree/master/ci.properties
|
||||||
|
(ci.properties is the only file you have to modify with the values requried for the specific branch.)
|
||||||
|
|
||||||
|
Packer Scripts - https://github.com/hyperledger/ci-management/blob/master/packer/provision/docker.sh
|
||||||
|
(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.)
|
||||||
|
|
||||||
|
#### How to reach out to CI team?
|
||||||
|
|
||||||
|
Post your questions or feedback in https://chat.hyperledger.org/channel/ci-pipeline or https://chat.hyperledger.org/channel/fabric-ci Rocket Chat channels. Also, you can create JIRA tasks or bugs in FABCI project. https://jira.hyperledger.org/projects/FABCI
|
||||||
BIN
docs/pipeline_flow.png
Normal file
BIN
docs/pipeline_flow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
|
|
@ -44,6 +44,7 @@ cd ../basic-network
|
||||||
# Now launch the CLI container in order to install, instantiate chaincode
|
# Now launch the CLI container in order to install, instantiate chaincode
|
||||||
# and prime the ledger with our 10 cars
|
# and prime the ledger with our 10 cars
|
||||||
docker-compose -f ./docker-compose.yml up -d cli
|
docker-compose -f ./docker-compose.yml up -d cli
|
||||||
|
docker ps -a
|
||||||
|
|
||||||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli \
|
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli \
|
||||||
peer lifecycle chaincode package fabcar.tar.gz --path "$CC_SRC_PATH" --lang "$CC_RUNTIME_LANGUAGE" --label fabcarv1
|
peer lifecycle chaincode package fabcar.tar.gz --path "$CC_SRC_PATH" --lang "$CC_RUNTIME_LANGUAGE" --label fabcarv1
|
||||||
|
|
|
||||||
|
|
@ -159,18 +159,24 @@ function networkUp() {
|
||||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||||
|
docker ps -a
|
||||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||||
|
docker ps -a
|
||||||
else
|
else
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||||
|
docker ps -a
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA up -d 2>&1
|
||||||
|
docker ps -a
|
||||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 up -d 2>&1
|
||||||
|
docker ps -a
|
||||||
else
|
else
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||||
|
docker ps -a
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
|
||||||
75
scripts/ci_scripts/byfn_eyfn.sh
Executable file
75
scripts/ci_scripts/byfn_eyfn.sh
Executable file
|
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp All Rights Reserved
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# docker container list
|
||||||
|
CONTAINER_LIST=(peer0.org1 peer1.org1 peer0.org2 peer1.org2 peer0.org3 peer1.org3 orderer)
|
||||||
|
COUCHDB_CONTAINER_LIST=(couchdb0 couchdb1 couchdb2 couchdb3 couchdb4 couchdb5)
|
||||||
|
|
||||||
|
cd $WORKSPACE/$BASE_DIR/first-network
|
||||||
|
# export path
|
||||||
|
export PATH=$WORKSPACE/$BASE_DIR/bin:$PATH
|
||||||
|
|
||||||
|
logs() {
|
||||||
|
# Create Logs directory
|
||||||
|
mkdir -p $WORKSPACE/Docker_Container_Logs
|
||||||
|
for CONTAINER in ${CONTAINER_LIST[*]}; do
|
||||||
|
docker logs $CONTAINER.example.com >& $WORKSPACE/Docker_Container_Logs/$CONTAINER-$1.log
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -z $2 ]; then
|
||||||
|
for CONTAINER in ${COUCHDB_CONTAINER_LIST[*]}; do
|
||||||
|
docker logs $CONTAINER >& $WORKSPACE/Docker_Container_Logs/$CONTAINER-$1.log
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
copy_logs() {
|
||||||
|
# Call logs function
|
||||||
|
logs $2 $3
|
||||||
|
if [ $1 != 0 ]; then
|
||||||
|
echo -e "\033[31m $2 test case is FAILED" "\033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo " ################ "
|
||||||
|
echo -e "\033[1m DEFAULT CHANNEL\033[0m"
|
||||||
|
echo " # ############## "
|
||||||
|
set -x
|
||||||
|
echo y | ./byfn.sh -m down
|
||||||
|
echo y | ./byfn.sh -m up -t 60
|
||||||
|
copy_logs $? default-channel
|
||||||
|
echo y | ./eyfn.sh -m up -t 60
|
||||||
|
copy_logs $? default-channel
|
||||||
|
echo y | ./eyfn.sh -m down
|
||||||
|
set +x
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo " ############################ "
|
||||||
|
echo -e "\033[1mCUSTOM CHANNEL - COUCHDB\033[0m"
|
||||||
|
echo " # ########################## "
|
||||||
|
set -x
|
||||||
|
echo y | ./byfn.sh -m up -c custom-channel-couchdb -s couchdb -t 75 -d 15
|
||||||
|
copy_logs $? custom-channel-couch couchdb
|
||||||
|
echo y | ./eyfn.sh -m up -c custom-channel-couchdb -s couchdb -t 75 -d 15
|
||||||
|
copy_logs $? custom-channel-couch
|
||||||
|
echo y | ./eyfn.sh -m down
|
||||||
|
set +x
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo " #################################### "
|
||||||
|
echo -e "\033[1m NODE CHAINCODE\033[0m"
|
||||||
|
echo " # ################################## "
|
||||||
|
set -x
|
||||||
|
echo y | ./byfn.sh -m up -l node -t 60
|
||||||
|
copy_logs $? default-channel-node
|
||||||
|
echo y | ./eyfn.sh -m up -l node -t 60
|
||||||
|
copy_logs $? default-channel-node
|
||||||
|
echo y | ./eyfn.sh -m down
|
||||||
|
set +x
|
||||||
54
scripts/ci_scripts/ciScript.sh
Executable file
54
scripts/ci_scripts/ciScript.sh
Executable file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp All Rights Reserved
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# exit on first error
|
||||||
|
|
||||||
|
Parse_Arguments() {
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--byfn_eyfn_Tests)
|
||||||
|
byfn_eyfn_Tests
|
||||||
|
;;
|
||||||
|
--fabcar_Tests)
|
||||||
|
fabcar_Tests
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# run byfn,eyfn tests
|
||||||
|
byfn_eyfn_Tests() {
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo " ____ __ __ _____ _ _ _____ __ __ _____ _ _ "
|
||||||
|
echo " | __ ) \ \ / / | ___| | \ | | | ____| \ \ / / | ___| | \ | | "
|
||||||
|
echo " | _ \ \ V / | |_ | \| | _____ | _| \ V / | |_ | \| | "
|
||||||
|
echo " | |_) | | | | _| | |\ | |_____| | |___ | | | _| | |\ | "
|
||||||
|
echo " |____/ |_| |_| |_| \_| |_____| |_| |_| |_| \_| "
|
||||||
|
|
||||||
|
./byfn_eyfn.sh
|
||||||
|
}
|
||||||
|
# run fabcar tests
|
||||||
|
fabcar_Tests() {
|
||||||
|
|
||||||
|
echo " #############################"
|
||||||
|
echo "npm version ------> $(npm -v)"
|
||||||
|
echo "node version ------> $(node -v)"
|
||||||
|
echo " #############################"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo " _____ _ ____ ____ _ ____ "
|
||||||
|
echo " | ___| / \ | __ ) / ___| / \ | _ \ "
|
||||||
|
echo " | |_ / _ \ | _ \ | | / _ \ | |_) | "
|
||||||
|
echo " | _| / ___ \ | |_) | | |___ / ___ \ | _ < "
|
||||||
|
echo " |_| /_/ \_\ |____/ \____| /_/ \_\ |_| \_\ "
|
||||||
|
|
||||||
|
./fabcar.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
Parse_Arguments $@
|
||||||
|
|
@ -28,11 +28,12 @@ if [ $1 != 0 ]; then
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd $BASE_FOLDER/fabric-samples/fabcar || exit
|
cd $WORKSPACE/$BASE_DIR/fabcar || exit
|
||||||
export PATH=gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH
|
export PATH=gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH
|
||||||
|
|
||||||
LANGUAGES="go javascript typescript"
|
LANGUAGES="go javascript typescript"
|
||||||
for LANGUAGE in ${LANGUAGES}; do
|
for LANGUAGE in ${LANGUAGES}; do
|
||||||
|
echo -e "\033[1m ${LANGUAGE} Test\033[0m"
|
||||||
echo -e "\033[32m starting fabcar test (${LANGUAGE})" "\033[0m"
|
echo -e "\033[32m starting fabcar test (${LANGUAGE})" "\033[0m"
|
||||||
# Start Fabric, and deploy the smart contract
|
# Start Fabric, and deploy the smart contract
|
||||||
./startFabric.sh ${LANGUAGE}
|
./startFabric.sh ${LANGUAGE}
|
||||||
Loading…
Reference in a new issue