Skip to content

Commit

Permalink
FABN-997 Update pipeline script
Browse files Browse the repository at this point in the history
Add color codes to print the color output on the jenkins
console.

Change-Id: If00ef5c8cc00b3b618fffb0db20f541f1b4e5f2f
Signed-off-by: rameshthoomu <[email protected]>
  • Loading branch information
rameshthoomu committed Nov 6, 2018
1 parent 1cdd627 commit b106818
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
17 changes: 9 additions & 8 deletions Jenkinsfile.x
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ node ('hyp-x') { // trigger build on x86_64 node
}
// clean environment and get env data
stage("Clean Environment - Get Env Info") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --clean_Environment --env_Info'
Expand All @@ -45,10 +46,11 @@ node ('hyp-x') { // trigger build on x86_64 node
failure_stage = "Clean Environment - Get Env Info"
throw err
}
}
}

// Pull fabric,fabric-ca and Javaenv
stage("Pull Docker images") {
stage("Pull Docker Images") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
Expand Down Expand Up @@ -80,26 +82,25 @@ node ('hyp-x') { // trigger build on x86_64 node
}

// Publish npm modules from merged job
if (env.GERRIT_EVENT_TYPE == 'change-merged') {
if (env.GERRIT_EVENT_TYPE == "change-merged") {
publishNpm()
} else {
echo "------> Don't publish npm modules from verify job"
echo -e "\033[32m ------> Dont publish npm modules from verify job" "\033[0m"
}

// Publish API Docs from merged job only
if (env.GERRIT_EVENT_TYPE == 'change-merged') {
if (env.GERRIT_EVENT_TYPE == "change-merged") {
apiDocs()
} else {
echo "------> Don't publish API Docs from verify job"
echo -e ""\033[32m" ------> Don't publish API Docs from verify job" "\033[0m"
}

} finally { // Code for coverage report
junit '**/cobertura-coverage.xml'
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.GERRIT_EVENT_TYPE == 'change-merged') {
if (env.GERRIT_EVENT_TYPE == "change-merged") {
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
rocketSend channel: "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - BUILD_URL: (<${env.BUILD_URL}|Open>)"
rocketSend "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - BUILD_URL: (<${env.BUILD_URL}|Open>)"
}
}
} // finally block end here
Expand Down
18 changes: 0 additions & 18 deletions Jenkinsfile.z
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ node('hyp-z') {
env.ARCH = "s390x" // `uname -m`
env.IMAGE_TAG = "${ARCH}-${VERSION}-stable" // fabric latest stable version from nexus
env.PROJECT_VERSION = "${VERSION}-stable"
env.BASE_IMAGE_VER = sh(returnStdout: true, script: 'cat Makefile | grep BASEIMAGE_RELEASE= | cut -d "=" -f2').trim() // BASEIMAGE Version from fabric Makefile
env.BASE_IMAGE_TAG = "${ARCH}-${BASE_IMAGE_VER}" //fabric baseimage version
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"
Expand Down Expand Up @@ -52,22 +50,6 @@ node('hyp-z') {
}
}

// Pull Couchdb Image
stage("Pull Couchdb image") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Thirdparty_Images'
}
}
catch (err) {
failure_stage = "Pull couchdb docker image"
currentBuild.result = 'FAILURE'
throw err
}
}
}

// Pull fabric, fabric-ca Docker Images
stage("Pull Docker Images") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
Expand Down
20 changes: 10 additions & 10 deletions scripts/Jenkins_Scripts/CI_Script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export ORG_NAME="hyperledger/fabric"

# error check
err_Check() {
echo "ERROR !!!! --------> $1 <---------"
echo "\033[31m $1" "\033[0m"
exit 1
}

Expand Down Expand Up @@ -97,7 +97,7 @@ env_Info() {
# This function prints system info

#### Build Env INFO
echo "-----------> Build Env INFO"
echo -e "\033[32m -----------> Build Env INFO" "\033[0m"
# Output all information about the Jenkins environment
uname -a
cat /etc/*-release
Expand All @@ -115,10 +115,10 @@ pull_Docker_Images() {
if [ $IMAGES == "javaenv" ]; then
if [ $ARCH == "s390x" ]; then
# Do not pull javaenv if OS_VER == s390x
echo "-----------> skipping pull of javaenv image on s390x"
echo "\033[32m -----------> skipping pull of javaenv image on s390x" "\033[0m"
else
# Pull javaenv at same level as node SDK
echo "-----------> pull $ORG_NAME-$IMAGES:${ARCH}-${IMAGE_TAG} image"
echo "\033[32m -----------> pull $ORG_NAME-$IMAGES:${IMAGE_TAG} image" "\033[0m"
echo
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG} > /dev/null 2>&1
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -149,7 +149,7 @@ pull_Docker_Images() {
# run sdk e2e tests
sdk_E2e_Tests() {
echo
echo "-----------> Execute NODE SDK Integration Tests"
echo -e "\033[32m Execute NODE SDK Integration Tests" "\033[0m"
cd ${WORKSPACE}/gopath/src/github.com/hyperledger/fabric-sdk-node || exit
# Install nvm to install multi node versions
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Expand All @@ -162,16 +162,16 @@ sdk_E2e_Tests() {
nvm install $NODE_VER || true
nvm use --delete-prefix v$NODE_VER --silent

echo "npm version ------> $(npm -v)"
echo "node version ------> $(node -v)"
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 && npm install -g istanbul
~/npm/bin/gulp || err_Check "ERROR!!! gulp failed"
~/npm/bin/gulp ca || err_Check "ERROR!!! gulp ca failed"
rm -rf node_modules && npm install || err_Check "ERROR!!! npm install failed"

echo "------> Run Node SDK Unit, FV, and scenario tests"
echo -e "\033[32m ------> Run Node SDK Unit, FV, and scenario tests" "\033[0m"
echo "============"
~/npm/bin/gulp test
if [ $? == 0 ]; then
Expand All @@ -186,14 +186,14 @@ sdk_E2e_Tests() {
# Publish npm modules after successful merge on amd64
publish_NpmModules() {
echo
echo "-----------> Publish npm modules from amd64"
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 "-----------> Publish NODE_SDK API docs after successful merge on amd64"
echo -e "\033[32m -----------> Publish NODE_SDK API docs after successful merge on amd64" "\033[0m"
./Publish_API_Docs.sh
}
Parse_Arguments $@

0 comments on commit b106818

Please sign in to comment.