From 84469f8ce2f81d7934682e2e5ebfbfa6254a6e8c Mon Sep 17 00:00:00 2001 From: vijaypunugubati Date: Mon, 26 Aug 2019 11:58:25 -0400 Subject: [PATCH] FABCI-381 Remove Zbuilds on cc-node for master Signed-off-by: vijaypunugubati Change-Id: I602d91801e588e112cb2f254ae6c926ff348927c --- Jenkinsfile.z | 160 -------------- package.json | 2 +- scripts/Jenkins_Scripts/CI_Script.sh | 307 ++++++++++++--------------- 3 files changed, 140 insertions(+), 329 deletions(-) delete mode 100644 Jenkinsfile.z diff --git a/Jenkinsfile.z b/Jenkinsfile.z deleted file mode 100644 index 00dbee87..00000000 --- a/Jenkinsfile.z +++ /dev/null @@ -1,160 +0,0 @@ -// 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/ - env.PROJECT_DIR = "gopath/src/github.com/hyperledger" - env.PROJECT = "fabric-chaincode-node" - env.GOPATH = "$WORKSPACE/gopath" - 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() - env.NODE_VER = "10.15.2" - env.ARCH = "s390x" - env.IMAGE_TAG = "${ARCH}-${VERSION}-stable" // fabric latest stable version from nexus - 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 -q "verify" && echo patchset || echo merge').trim() - def failure_stage = "none" -// delete working directory - deleteDir() - stage("Fetch Patchset") { - cleanWs() - try { - if (jobname == "patchset") { - println "IN VERIFY 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']]]) - dir("${ROOTDIR}/$PROJECT_DIR") { - sh ''' - # Clone fabric repository - git clone --single-branch -b $GERRIT_BRANCH https://github.com/hyperledger/fabric - # Clone fabric-samples repository - git clone --single-branch -b $GERRIT_BRANCH --depth=1 https://github.com/hyperledger/fabric-samples - ''' - } - } else { - // Clone fabric-chaincode-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") { - sh ''' - # Clone fabric repository - git clone --single-branch -b $GERRIT_BRANCH https://github.com/hyperledger/fabric - # Clone fabric-samples repository - git clone --single-branch -b $GERRIT_BRANCH --depth=1 https://github.com/hyperledger/fabric-samples - ''' - } - } - 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") { - // wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-chaincode-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 - } - // } - } - -// Pull Fabric, Fabric-ca Images - stage("Pull Docker Images") { - // wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-chaincode-node/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 gulp tests (e2e tests) - stage("Run Headless & E2E Tests") { - // wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-chaincode-node/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --e2e_Tests' - } - } - catch (err) { - failure_stage = "e2e_Tests" - currentBuild.result = 'FAILURE' - throw err - } - // } - } - -// Publish hyperledger/fabric-nodeenv image from merged job only -if (env.JOB_NAME == "fabric-chaincode-node-merge-s390x") { - publishNodeenv() -} else { - echo "------> Don't publish nodeenv image from verify job" - } - } finally { // Code for coverage report - step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/cobertura-coverage.xml', failUnhealthy: false, failUnstable: false, failNoReports: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false]) - archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log' - if (env.JOB_NAME == "fabric-chaincode-node-merge-s390x") { - if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE - rocketSend "Build Notification - STATUS: *${currentBuild.result}* - BRANCH: *${env.GERRIT_BRANCH}* - PROJECT: *${env.PROJECT}* - BUILD_URL - (<${env.BUILD_URL}|Open>)" - } - } - } // finally block - } // timestamps block -} // node block -} // timeout block - -def publishNodeenv() { -// Publish Chaincode_node nodeenv image after successful merge - stage("Publish nodeenv image") { - def ROOTDIR = pwd() - configFileProvider([configFile(fileId: 'fabric-settings', variable: 'SETTINGS_FILE')]) { - // wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-chaincode-node/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --publish_Nodeenv_Image' - } - } - catch (err) { - failure_stage = "publish_nodeenv_image" - currentBuild.result = 'FAILURE' - throw err - } - // } - } - } -} diff --git a/package.json b/package.json index 5f19be3f..5ae28794 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.0.0-snapshot", "description": "fabric-shim, fabric-shim-crypto", "testFabricVersion": "master", - "testFabricThirdParty": "0.4.14", + "testFabricThirdParty": "0.4.15", "docsLatestVersion": "release-1.4", "engines": { "node": "10.15.2", diff --git a/scripts/Jenkins_Scripts/CI_Script.sh b/scripts/Jenkins_Scripts/CI_Script.sh index 994d3e4c..ad61dd43 100755 --- a/scripts/Jenkins_Scripts/CI_Script.sh +++ b/scripts/Jenkins_Scripts/CI_Script.sh @@ -11,80 +11,79 @@ export ORG_NAME="hyperledger/fabric" export CONTAINER_LIST=(ca orderer peer0.org1) # error check -err_Check() { - echo -e "\033[31m $1" "\033[0m" - docker images | grep hyperledger && docker ps -a - # Write ca, orderer, peer logs - for CONTAINER in ${CONTAINER_LIST[*]}; do - docker logs $CONTAINER.example.com >& $CONTAINER.log - done - # Write cli container logs into cli.log file - docker logs cli >& cli.log - # Write couchdb container logs into couchdb.log file - docker logs couchdb >& couchdb.log - # Copy debug log - cp /tmp/fabric-shim/logs/*.log $WORKSPACE - exit 1 +err_and_exit() { + echo -e "\033[31m $1" "\033[0m" + docker images | grep hyperledger && docker ps -a + # Write ca, orderer, peer logs + for CONTAINER in ${CONTAINER_LIST[*]}; do + docker logs $CONTAINER.example.com >& $CONTAINER.log + done + # Write cli container logs into cli.log file + docker logs cli >& cli.log + # Write couchdb container logs into couchdb.log file + docker logs couchdb >& couchdb.log + # Copy debug log + cp /tmp/fabric-shim/logs/*.log $WORKSPACE + exit 1 } Parse_Arguments() { - while [ $# -gt 0 ]; do - case $1 in - --env_Info) - env_Info - ;; - --clean_Environment) - clean_Environment - ;; - --pull_Docker_Images) - pull_Docker_Images - ;; - --e2e_Tests) - e2e_Tests - ;; - --publish_NpmModules) - publish_NpmModules - ;; - --publish_ApiDocs) - publish_ApiDocs - ;; - --publish_Nodeenv_Image) - publish_Nodeenv_Image - ;; - esac - shift - done + while [ $# -gt 0 ]; do + case $1 in + --env_Info) + env_Info + ;; + --clean_Environment) + clean_Environment + ;; + --pull_Docker_Images) + pull_Docker_Images + ;; + --e2e_Tests) + e2e_Tests + ;; + --publish_NpmModules) + publish_NpmModules + ;; + --publish_ApiDocs) + publish_ApiDocs + ;; + --publish_Nodeenv_Image) + publish_Nodeenv_Image + ;; + esac + shift + done } clean_Environment() { - echo "-----------> Clean Docker Containers & Images, unused/lefover build artifacts" function clearContainers () { - CONTAINER_IDS=$(docker ps -aq) - if [ -z "$CONTAINER_IDS" ] || [ "$CONTAINER_IDS" = " " ]; then - echo "---- No containers available for deletion ----" + CONTAINER_IDS=$(docker ps -aq) + if [ -z "$CONTAINER_IDS" ] || [ $CONTAINER_IDS == " " ]; then + echo "---- No containers available for deletion ----" else - docker rm -f $CONTAINER_IDS || true - docker ps -a + docker rm -f $CONTAINER_IDS || true + docker ps -a fi } function removeUnwantedImages() { - DOCKER_IMAGES_SNAPSHOTS=$(docker images | grep snapshot | grep -v grep | awk '{print $1":" $2}') + DOCKER_IMAGES_SNAPSHOTS=$(docker images | grep snapshot | grep -v grep | awk '{print $1":" $2}') - if [ -z "$DOCKER_IMAGES_SNAPSHOTS" ] || [ "$DOCKER_IMAGES_SNAPSHOTS" = " " ]; then - echo "---- No snapshot images available for deletion ----" - else - docker rmi -f $DOCKER_IMAGES_SNAPSHOTS || true - fi - DOCKER_IMAGE_IDS=$(docker images | grep -v 'couchdb\|kafka\|zookeeper\|cello' | awk '{print $3}') + if [ -z "$DOCKER_IMAGES_SNAPSHOTS" ] || [ $DOCKER_IMAGES_SNAPSHOTS == " " ]; then + echo "---- No snapshot images available for deletion ----" + else + docker rmi -f $DOCKER_IMAGES_SNAPSHOTS || true + fi + DOCKER_IMAGE_IDS=$(docker images | grep -v 'couchdb\|kafka\|zookeeper\|cello' | awk '{print $3}') - if [ -z "$DOCKER_IMAGE_IDS" ] || [ "$DOCKER_IMAGE_IDS" = " " ]; then - echo "---- No images available for deletion ----" - else - docker rmi -f $DOCKER_IMAGE_IDS || true - docker images - fi + if [ -z "$DOCKER_IMAGE_IDS" ] || [ "$DOCKER_IMAGE_IDS" = " " ]; then + echo "---- No images available for deletion ----" + else + docker rmi -f $DOCKER_IMAGE_IDS || true + docker images + fi } # Delete nvm prefix & then delete nvm @@ -109,67 +108,50 @@ removeUnwantedImages } env_Info() { - # This function prints system info - - #### Build Env INFO - echo "-----------> Build Env INFO" - # Output all information about the Jenkins environment - uname -a - cat /etc/*-release - env - gcc --version - docker version - docker info - docker-compose version - pgrep -a docker - docker images - docker ps -a + # This function prints system info + + #### Build Env INFO + echo "-----------> Build Env INFO" + # Output all information about the Jenkins environment + uname -a + cat /etc/*-release + env + gcc --version + docker version + docker info + docker-compose version + pgrep -a docker + docker images + docker ps -a } # pull fabric, ca images from nexus pull_Docker_Images() { - for IMAGES in peer orderer tools ccenv ca baseos; do - docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo -e "\033[31m FAILED to pull docker images" "\033[0m" - exit 1 - fi - echo "\033[32m ----------> pull $IMAGES image" "\033[0m" - echo - docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES - docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${ARCH}-${VERSION} - docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${VERSION} - docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} - done - echo - docker images | grep hyperledger/fabric + for IMAGES in peer orderer tools ccenv ca baseos; do + docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "\033[31m FAILED to pull docker images" "\033[0m" + exit 1 + fi + echo "\033[32m ----------> pull $IMAGES image" "\033[0m" + echo + docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES + docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${ARCH}-${VERSION} + docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} $ORG_NAME-$IMAGES:${VERSION} + docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} + done + echo + docker images | grep hyperledger/fabric } # Install NPM install_Npm() { - echo "-------> ARCH:" $ARCH - if [[ $ARCH == "s390x" || $ARCH == "ppc64le" ]]; then - # Source nvmrc.sh - source /etc/profile.d/nvmrc.sh - echo "------> Install NodeJS" - # This also depends on the fabric-baseimage. Make sure you modify there as well. - echo "------> Use $NODE_VER" - nvm install $NODE_VER || true - nvm use --delete-prefix v$NODE_VER --silent - + if [[ $ARCH == "amd64" ]]; then echo -e "\033[32m npm version ------> $(npm -v)" "\033[0m" echo -e "\033[32m node version ------> $(node -v)" "\033[0m" - npm install || err_Check "ERROR!!! npm install failed" - npm config set prefix ~/npm && npm install -g gulp - - else - - echo -e "\033[32m npm version ------> $(npm -v)" "\033[0m" - echo -e "\033[32m node version ------> $(node -v)" "\033[0m" - - npm install || err_Check "ERROR!!! npm install failed" + npm install || err_and_exit "ERROR!!! npm install failed" npm install -g gulp fi } @@ -177,88 +159,77 @@ install_Npm() { # run sdk e2e tests e2e_Tests() { - echo -e "\033[32m Execute Chaincode Node Integration Tests" "\033[0m" - cd ${WORKSPACE}/gopath/src/github.com/hyperledger/fabric-chaincode-node - - # Install NPM before start the tests - install_Npm + echo -e "\033[32m Execute Chaincode Node Integration Tests" "\033[0m" + cd ${WORKSPACE}/gopath/src/github.com/hyperledger/fabric-chaincode-node - echo "#################################################" - echo -e "\033[32m ------> Run Headless Tests" "\033[0m" - echo "#################################################" + # Install NPM before start the tests + install_Npm - gulp test-headless || err_Check "ERROR!!! test-headless failed" + echo "#################################################" + echo -e "\033[32m ------> Run Headless Tests" "\033[0m" + echo "#################################################" - echo "#################################################################" - echo -e "\033[32m ------> Run Integration and Scenario Tests" "\033[0m" - echo "#################################################################" + gulp test-headless || err_and_exit "ERROR!!! test-headless failed" - gulp docker-image-build - docker images | grep hyperledger && docker ps -a + echo "#################################################################" + echo -e "\033[32m ------> Run Integration and Scenario Tests" "\033[0m" + echo "#################################################################" - DEVMODE=false gulp channel-init || err_Check "ERROR!!! channel-init failed" - gulp test-e2e || err_Check "ERROR!!! test-e2e failed" + gulp docker-image-build + docker images | grep hyperledger && docker ps -a - if [[ $ARCH == "s390x" || $ARCH == "ppc64le" ]]; then - echo "###############################################" - echo -e "\033[32m ------> Not running DevMode tests" "\033[0m" - echo "###############################################" + DEVMODE=false gulp channel-init || err_and_exit "ERROR!!! channel-init failed" + gulp test-e2e || err_and_exit "ERROR!!! test-e2e failed" - echo "###############################################" - echo -e "\033[32m ------> Not running InvCtrl tests" "\033[0m" - echo "###############################################" - else - - echo "###############################################" - echo -e "\033[32m ------> Run DevMode tests" "\033[0m" - echo "###############################################" + echo "###############################################" + echo -e "\033[32m ------> Run DevMode tests" "\033[0m" + echo "###############################################" - DEVMODE=true gulp channel-init || err_Check "ERROR!!! channel-init failed" - gulp test-devmode || err_Check "ERROR!!! test-devmode failed" + DEVMODE=true gulp channel-init || err_and_exit "ERROR!!! channel-init failed" + gulp test-devmode || err_and_exit "ERROR!!! test-devmode failed" - echo "###############################################" - echo -e "\033[32m ------> Run InvCtrl tests" "\033[0m" - echo "###############################################" + echo "###############################################" + echo -e "\033[32m ------> Run InvCtrl tests" "\033[0m" + echo "###############################################" - DEVMODE=true gulp channel-init || err_Check "ERROR!!! channel-init failed" - gulp test-invctrl || err_Check "ERROR!!! test-invctrl failed" - fi + DEVMODE=true gulp channel-init || err_and_exit "ERROR!!! channel-init failed" + gulp test-invctrl || err_and_exit "ERROR!!! test-invctrl failed" - echo "#############################################" - echo -e "\033[32m ------> Tests Complete" "\033[0m" - echo "#############################################" + echo "#############################################" + echo -e "\033[32m ------> Tests Complete" "\033[0m" + echo "#############################################" } # Publish nodeenv docker image after successful merge publish_Nodeenv_Image() { - echo - echo -e "\033[32m -----------> Publish nodeenv docker image" "\033[0m" - # 10003 points to docker.snapshot - DOCKER_REPOSITORY=nexus3.hyperledger.org:10003 - # SETTINGS_FILE stores the nexus credentials - USER=$(xpath -e "//servers/server[id='$DOCKER_REPOSITORY']/username/text()" "$SETTINGS_FILE") - PASS=$(xpath -e "//servers/server[id='$DOCKER_REPOSITORY']/password/text()" "$SETTINGS_FILE") - docker login $DOCKER_REPOSITORY -u "$USER" -p "$PASS" - # tag nodeenv latest tag to nexus3 repo - docker tag hyperledger/fabric-nodeenv $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-latest - docker tag hyperledger/fabric-nodeenv $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-$VERSION-stable - # Push nodeenv image to nexus3 docker.snapshot - docker push $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-latest - docker push $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-$VERSION-stable - docker images + echo + echo -e "\033[32m -----------> Publish nodeenv docker image" "\033[0m" + # 10003 points to docker.snapshot + DOCKER_REPOSITORY=nexus3.hyperledger.org:10003 + # SETTINGS_FILE stores the nexus credentials + USER=$(xpath -e "//servers/server[id='$DOCKER_REPOSITORY']/username/text()" "$SETTINGS_FILE") + PASS=$(xpath -e "//servers/server[id='$DOCKER_REPOSITORY']/password/text()" "$SETTINGS_FILE") + docker login $DOCKER_REPOSITORY -u "$USER" -p "$PASS" + # tag nodeenv latest tag to nexus3 repo + docker tag hyperledger/fabric-nodeenv $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-latest + docker tag hyperledger/fabric-nodeenv $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-$VERSION-stable + # Push nodeenv image to nexus3 docker.snapshot + docker push $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-latest + docker push $DOCKER_REPOSITORY/hyperledger/fabric-nodeenv:$ARCH-$VERSION-stable + docker images } # Publish npm modules after successful merge on amd64 publish_NpmModules() { - echo - echo -e "\033[32m -----------> Publish npm modules from amd64" "\033[0m" - ./Publish_NPM_Modules.sh + echo + echo -e "\033[32m -----------> Publish npm modules from amd64" "\033[0m" + ./Publish_NPM_Modules.sh } # Publish NODE_SDK API docs after successful merge on amd64 publish_ApiDocs() { - echo - echo -e "\033[32m -----------> Publish NODE_SDK API docs after successful merge on amd64" "\033[0m" - ./Publish_API_Docs.sh + echo + echo -e "\033[32m -----------> Publish NODE_SDK API docs after successful merge on amd64" "\033[0m" + ./Publish_API_Docs.sh } Parse_Arguments $@