Skip to content

Commit

Permalink
FABN-981 Update pipeline scripts
Browse files Browse the repository at this point in the history
Change-Id: Ie6b53adca6a0df71b87b7595f9efcf9c79262e95
Signed-off-by: rameshthoomu <[email protected]>
  • Loading branch information
rameshthoomu committed Oct 24, 2018
1 parent 0e63ea2 commit e3fd07b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 30 deletions.
12 changes: 12 additions & 0 deletions Jenkinsfile.x
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
//
node ('hyp-x') { // trigger build on x86_64 node
timestamps {
try {
def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>
env.NODE_VER = "8.11.3"
Expand All @@ -16,6 +17,7 @@ node ('hyp-x') { // trigger build on x86_64 node
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}"){
sh '''
Expand All @@ -30,9 +32,11 @@ node ('hyp-x') { // trigger build on x86_64 node
failure_stage = "Fetch patchset"
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-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --clean_Environment --env_Info'
Expand All @@ -42,10 +46,12 @@ node ('hyp-x') { // trigger build on x86_64 node
failure_stage = "Clean Environment - Get Env Info"
throw err
}
}
}

// 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'
Expand All @@ -55,10 +61,12 @@ node ('hyp-x') { // trigger build on x86_64 node
failure_stage = "Pull couchdb docker image"
throw err
}
}
}

// Pull Docker Images
stage("Pull Docker images") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Fabric_Images'
Expand All @@ -68,10 +76,12 @@ node ('hyp-x') { // trigger build on x86_64 node
failure_stage = "Pull docker images"
throw err
}
}
}

// Run gulp tests (headless and e2e tests)
stage("Run gulp_Tests") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --sdk_E2e_Tests'
Expand All @@ -81,6 +91,7 @@ node ('hyp-x') { // trigger build on x86_64 node
failure_stage = "sdk_E2e_Tests"
throw err
}
}
}

// Publish unstable npm modules from merged job
Expand All @@ -102,6 +113,7 @@ if (env.GERRIT_EVENT_TYPE == "change-merged") {
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/cobertura-coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
archiveArtifacts artifacts: '**/*.log'
} // finally block end here
} // timestamps end here
} // node block end here

def unstableNpm() {
Expand Down
12 changes: 12 additions & 0 deletions Jenkinsfile.z
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
// SPDX-License-Identifier: Apache-2.0
//
node('hyp-z') {
timestamps {
try {

def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>
env.NODE_VER = "8.11.3"
env.GO_VER = "1.11.1"
env.PROJECT_DIR = "gopath/src/github.com/hyperledger"
env.NODE_VER = "8.11.3"
env.GO_VER = "1.11.1"
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"
env.GOROOT = "/opt/go/go${GO_VER}.linux.s390x"
Expand All @@ -17,6 +20,7 @@ node('hyp-z') {
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}"){
sh '''
Expand All @@ -31,9 +35,11 @@ node('hyp-z') {
failure_stage = "Fetch patchset"
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-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --clean_Environment --env_Info'
Expand All @@ -56,10 +62,12 @@ node('hyp-z') {
failure_stage = "Pull couchdb docker image"
throw err
}
}
}

// Pull Docker Images
stage("Pull Docker images") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Fabric_Images'
Expand All @@ -69,10 +77,12 @@ node('hyp-z') {
failure_stage = "Pull docker images"
throw err
}
}
}

// Run gulp tests (headless and e2e tests)
stage("Run gulp_Tests") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --sdk_E2e_Tests'
Expand All @@ -82,10 +92,12 @@ node('hyp-z') {
failure_stage = "sdk_E2e_Tests"
throw err
}
}
}
} finally { // Code for coverage report
junit '**/cobertura-coverage.xml'
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/cobertura-coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
archiveArtifacts artifacts: '**/*.log'
} // finally block end here
} // timestamps end here
} // node block end here
38 changes: 19 additions & 19 deletions scripts/Jenkins_Scripts/CI_Script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
# exit on first error

export BASE_FOLDER=$WORKSPACE/gopath/src/github.com/hyperledger
export STABLE_TAG=1.3.0-stable
export NEXUS_REPO_URL=nexus3.hyperledger.org:10001
# Modify this when change the image tag
export STABLE_TAG=1.4.0-stable
export NEXUS_URL=nexus3.hyperledger.org:10001
export ORG_NAME="hyperledger/fabric"

# Fetch baseimage version
Expand All @@ -20,11 +21,6 @@ export OS_VER=$(dpkg --print-architecture)
echo "-----------> OS_VER" $OS_VER
export BASE_IMAGE_TAG=$OS_VER-$BASE_IMAGE_VER

# Fetch Go Version from fabric ci.properties file
curl -L https://raw.githubusercontent.com/hyperledger/fabric/master/ci.properties > ci.properties
export GO_VER=`cat ci.properties | grep GO_VER | cut -d "=" -f 2`
echo "-----------> GO_VER" $GO_VER

# Published stable version from nexus
export STABLE_TAG=$OS_VER-$STABLE_TAG
echo "-----------> STABLE_TAG" $STABLE_TAG
Expand Down Expand Up @@ -127,30 +123,36 @@ env_Info() {
docker info
docker-compose version
pgrep -a docker
docker images
docker ps -a
}

# Pull Thirdparty Docker images (couchdb)
pull_Thirdparty_Images() {
for IMAGES in couchdb; do
echo "-----------> Pull $IMAGE image"
echo
docker pull $ORG_NAME-$IMAGES:$BASE_IMAGE_TAG
docker pull $ORG_NAME-$IMAGES:$BASE_IMAGE_TAG > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "\033[31m FAILED to download docker images" "\033[0m"
exit 1
fi
docker tag $ORG_NAME-$IMAGES:$BASE_IMAGE_TAG $ORG_NAME-$IMAGES
done
echo
docker images | grep hyperledger/fabric
}
# pull fabric images from nexus
pull_Fabric_Images() {
# pull fabric, fabric-ca images from nexus
pull_Docker_Images() {
for IMAGES in peer orderer ca; do
echo "-----------> pull $IMAGES image"
echo
docker pull $NEXUS_REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
docker tag $NEXUS_REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES
docker tag $NEXUS_REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES:$STABLE_TAG
docker rmi -f $NEXUS_REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "\033[31m FAILED to download docker images" "\033[0m"
exit 1
fi
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES:$STABLE_TAG
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
done
echo
docker images | grep hyperledger/fabric
Expand All @@ -162,15 +164,13 @@ sdk_E2e_Tests() {
echo "-----------> Execute NODE SDK E2E Tests"
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.2/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# shellcheck source=/dev/null
export NVM_DIR="$HOME/.nvm"
# shellcheck source=/dev/null
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

echo "------> Install NodeJS"
# This also depends on the fabric-baseimage. Make sure you modify there as well.
echo "------> Use $NODE_VER for >=release-1.1 branches"
nvm install $NODE_VER || true
nvm use --delete-prefix v$NODE_VER --silent

Expand Down
17 changes: 6 additions & 11 deletions scripts/Jenkins_Scripts/Publish_NPM_Modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ npmPublish() {
print ver}')

echo "===> UNSTABLE VERSION --> $UNSTABLE_VER"

UNSTABLE_VER=$(npm dist-tags ls "$1" | awk '/$CURRENT_TAG/{
UNSTABLE_INCREMENT=$(npm dist-tags ls "$1" | awk '/$CURRENT_TAG/{
ver=$NF
rel=$NF
sub(/.*\./,"",rel)
Expand Down Expand Up @@ -59,21 +58,17 @@ versions() {
echo "===> Current Version --> $RELEASE_VERSION"
}

# Publish unstable npm modules from amd64 ARCH
cd $WORKSPACE/gopath/src/github.com/hyperledger/fabric-sdk-node
echo "npm version ------> $(npm -v)"
echo "node version ------> $(node -v)"

ARCH=$(uname -m)
echo "-------> ARCH" $ARCH
echo "----------> ARCH" $ARCH

if [[ "$ARCH" = "s390x" ]] || [[ "$ARCH" = "ppc64le" ]]; then
echo "--------> Publish npm modules only from x86_64 (x) platform, not from $ARCH (z and p) now. <----"
echo "-------> Publish npm modules only from x86_64 (x) platform, not from $ARCH (z or p) <---------"
else
echo "----------> Publish npm node modules from $ARCH <--------"
echo "-------> Publish npm node modules from $ARCH <----------"
cd $WORKSPACE/gopath/src/github.com/hyperledger/fabric-sdk-node
# Set NPM_TOKEN from CI configuration
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN

# Publish fabric-ca-client node module
cd fabric-ca-client
versions
Expand Down

0 comments on commit e3fd07b

Please sign in to comment.