Skip to content

Commit

Permalink
FABCI-22 Pipeline job configuration
Browse files Browse the repository at this point in the history
Update npm node module and docs publish script with the
latest changes

Change-Id: Ibbb0af25422faae10ce4ae19f9e1500aeda8e6f0
Signed-off-by: rameshthoomu <rameshbabu.thoomu@gmail.com>
  • Loading branch information
rameshthoomu committed Oct 17, 2018
1 parent 792d86f commit e6df05b
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 98 deletions.
13 changes: 7 additions & 6 deletions Jenkinsfile.x
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
node ('hyp-x') { // trigger build on x86_64 node
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.GOPATH = "$WORKSPACE/gopath"
env.JAVA_HOME = "/usr/lib/jvm/java-1.8.0-openjdk-amd64"
env.PATH = "$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:~/npm/bin:/home/jenkins/.nvm/versions/node/v6.9.5/bin:/home/jenkins/.nvm/versions/node/v8.9.4/bin:$PATH"
env.GOROOT = "/opt/go/go1.10.linux.amd64"
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_VER}.linux.amd64"
env.PATH = "$GOROOT/bin:$PATH"
def failure_stage = "none"
// delete working directory
Expand Down Expand Up @@ -56,15 +57,15 @@ node ('hyp-x') { // trigger build on x86_64 node
}
}

// Pull Fabric, Fabric-ca Images
// Pull Docker Images
stage("Pull Docker images") {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Fabric_Images --pull_Fabric_CA_Image'
sh './CI_Script.sh --pull_Fabric_Images'
}
}
catch (err) {
failure_stage = "Pull fabric, fabric-ca docker images"
failure_stage = "Pull docker images"
throw err
}
}
Expand Down
13 changes: 8 additions & 5 deletions Jenkinsfile.z
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
//
node('hyp-z') {
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.GOPATH = "$WORKSPACE/gopath"
env.PATH = "$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:~/npm/bin:/home/jenkins/.nvm/versions/node/v6.9.5/bin:/home/jenkins/.nvm/versions/node/v8.9.4/bin:$PATH"
env.GOROOT = "/opt/go/go1.10.linux.s390x"
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"
env.PATH = "$GOROOT/bin:$PATH"
def failure_stage = "none"
// delete working directory
Expand Down Expand Up @@ -55,15 +58,15 @@ node('hyp-z') {
}
}

// Pull Fabric, Fabric-ca Images
// Pull Docker Images
stage("Pull Docker images") {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Fabric_Images --pull_Fabric_CA_Image'
sh './CI_Script.sh --pull_Fabric_Images'
}
}
catch (err) {
failure_stage = "Pull fabric, fabric-ca docker images"
failure_stage = "Pull docker images"
throw err
}
}
Expand Down
40 changes: 7 additions & 33 deletions scripts/Jenkins_Scripts/CI_Script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
# exit on first error

export BASE_FOLDER=$WORKSPACE/gopath/src/github.com/hyperledger
# Modify this when change the image tag
export STABLE_TAG=1.3.0-stable
export NEXUS_URL=nexus3.hyperledger.org:10001
export NEXUS_REPO_URL=nexus3.hyperledger.org:10001
export ORG_NAME="hyperledger/fabric"
# Set this in GOPATH
export NODE_VER=8.9.4 # Default nodejs version

# Fetch baseimage version
curl -L https://raw.githubusercontent.com/hyperledger/fabric/master/Makefile > Makefile
Expand Down Expand Up @@ -47,9 +44,6 @@ Parse_Arguments() {
--pull_Fabric_Images)
pull_Fabric_Images
;;
--pull_Fabric_CA_Image)
pull_Fabric_CA_Image
;;
--clean_Environment)
clean_Environment
;;
Expand Down Expand Up @@ -150,41 +144,22 @@ pull_Thirdparty_Images() {
}
# pull fabric images from nexus
pull_Fabric_Images() {
for IMAGES in peer orderer; do
for IMAGES in peer orderer ca; do
echo "-----------> pull $IMAGES image"
echo
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
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
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
done
echo
docker images | grep hyperledger/fabric
}
# pull fabric-ca images from nexus
pull_Fabric_CA_Image() {
echo
for IMAGES in ca; do
echo "-----------> pull $IMAGES image"
echo
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
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-ca
}

# run sdk e2e tests
sdk_E2e_Tests() {
echo
echo "-----------> Execute NODE SDK E2E Tests"
cd ${WORKSPACE}/gopath/src/github.com/hyperledger/fabric-sdk-node/test/fixtures || exit
docker-compose up >> dockerlogfile.log 2>&1 &
sleep 30
echo "---------> LIST DOCKER CONTAINERS"
docker ps -a

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
Expand All @@ -197,7 +172,6 @@ sdk_E2e_Tests() {
# 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
# use nodejs 8.9.4 version
nvm use --delete-prefix v$NODE_VER --silent

echo "npm version ------> $(npm -v)"
Expand Down
2 changes: 0 additions & 2 deletions scripts/Jenkins_Scripts/Publish_API_Docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ echo "-------> SDK_COMMIT:" $SDK_COMMIT
TARGET_REPO=$NODE_SDK_USERNAME.github.io.git
# Clone SDK_NODE API doc repository
git clone https://github.com/$NODE_SDK_USERNAME/$TARGET_REPO
# Remove API docs target repository
rm -rf $NODE_SDK_USERNAME.github.io/*
# Copy API docs to target repository & push to gh-pages URL
cp -r docs/gen/* $NODE_SDK_USERNAME.github.io
cd $NODE_SDK_USERNAME.github.io
Expand Down
108 changes: 56 additions & 52 deletions scripts/Jenkins_Scripts/Publish_NPM_Modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,40 @@
#

npmPublish() {
if [ $RELEASE = "snapshot" ]; then

if [[ "$CURRENT_TAG" = *"unstable"* ]] || [[ "$CURRENT_TAG" = *"skip"* ]]; then
echo
UNSTABLE_VER=$(npm dist-tags ls "$1" | awk '/unstable/{
UNSTABLE_VER=$(npm dist-tags ls "$1" | awk "/$CURRENT_TAG"":"/'{
ver=$NF
sub(/.*\./,"",rel)
sub(/\.[[:digit:]]+$/,"",ver)
print ver}')

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

UNSTABLE_INCREMENT=$(npm dist-tags ls "$1" | awk '/unstable/{
UNSTABLE_VER=$(npm dist-tags ls "$1" | awk '/$CURRENT_TAG/{
ver=$NF
rel=$NF
sub(/.*\./,"",rel)
sub(/\.[[:digit:]]+$/,"",ver)
print ver"."rel+1}')

echo "===> Incremented UNSTABLE VERSION --> $UNSTABLE_INCREMENT"

# Get last digit of the unstable version of $CURRENT_TAG
UNSTABLE_INCREMENT=$(echo $UNSTABLE_INCREMENT| rev | cut -d '.' -f 1 | rev)
echo "--------> UNSTABLE_INCREMENT : $UNSTABLE_INCREMENT"

# Append last digit with the package.json version
export UNSTABLE_INCREMENT_VERSION=$RELEASE_VERSION.$UNSTABLE_INCREMENT
echo "--------> UNSTABLE_INCREMENT_VERSION" $UNSTABLE_INCREMENT_VERSION


# Replace existing version with $UNSTABLE_INCREMENT_VERSION
sed -i 's/\(.*\"version\"\: \"\)\(.*\)/\1'$UNSTABLE_INCREMENT_VERSION\"\,'/' package.json
npm publish --tag $CURRENT_TAG

#if [ "$1" = "fabric-network" ]; then
# sed -i 's/\(.*\"fabric-client\"\: \"\)\(.*\)/\1'$CLIENT_VER\"\,'/' package.json
# sed -i 's/\(.*\"fabric-ca-client\"\: \"\)\(.*\)/\1'$CA_CLIENT_VER\"\,'/' package.json
#fi

if [ "$UNSTABLE_VER" = "$CURRENT_RELEASE" ]; then
# Replace existing version with Incremented $UNSTABLE_VERSION
sed -i 's/\(.*\"version\"\: \"\)\(.*\)/\1'$UNSTABLE_INCREMENT\"\,'/' package.json
npm publish --tag unstable
PUBLISHED_VER=$UNSTABLE_INCREMENT
else
# Replace existing version with $CURRENT_RELEASE
sed -i 's/\(.*\"version\"\: \"\)\(.*\)/\1'$CURRENT_RELEASE\"\,'/' package.json
npm publish --tag unstable
PUBLISHED_VER=$CURRENT_RELEASE
fi
else
if [[ "$RELEASE" =~ alpha*|preview*|beta*|rc*|^[0-9].[0-9].[0-9]$ ]]; then
echo "----> Publish $RELEASE from fabric-sdk-node-npm-release-x86_64 job"
fi
fi
}

Expand All @@ -53,44 +48,53 @@ npmPublish() {
# Fetch release version
#
##########################

versions() {

CURRENT_RELEASE=$(cat package.json | grep version | awk -F\" '{ print $4 }')
echo "===> Current Version --> $CURRENT_RELEASE"
RELEASE=$(cat package.json | grep version | awk -F\" '{ print $4 }' | cut -d "-" -f 2)
echo "===> Current Release --> $RELEASE"
# Get the unstable tag from package.json
CURRENT_TAG=$(cat package.json | grep tag | awk -F\" '{ print $4 }')
echo "===> Current TAG --> $CURRENT_TAG"

# Get the version from package.json
RELEASE_VERSION=$(cat package.json | grep version | awk -F\" '{ print $4 }')
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)"

npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN

# publish fabric-ca-client node module
cd fabric-ca-client
versions
npmPublish fabric-ca-client
CA_CLIENT_VER=$PUBLISHED_VER

# publish fabric-client node module
cd ../fabric-client
versions
npmPublish fabric-client
CLIENT_VER=$PUBLISHED_VER

# publish fabric-network node module
if [ -d "../fabric-network" ]; then
cd ../fabric-network
versions
npmPublish fabric-network
fi
ARCH=$(uname -m)
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. <----"
else
echo "----------> Publish npm node modules from $ARCH <--------"
cd $WORKSPACE/gopath/src/github.com/hyperledger/fabric-sdk-node
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN

# Publish fabric-ca-client node module
cd fabric-ca-client
versions
npmPublish fabric-ca-client

# Publish fabric-client node module
cd ../fabric-client
versions
npmPublish fabric-client

# Publish fabric-network node module
if [ -d "../fabric-network" ]; then
cd ../fabric-network
versions
npmPublish fabric-network
fi

# publish fabric-common node module
if [ -d "../fabric-common" ]; then
cd ../fabric-common
versions
npmPublish fabric-common
# Publish fabric-common node module
if [ -d "../fabric-common" ]; then
cd ../fabric-common
versions
npmPublish fabric-common
fi
fi

0 comments on commit e6df05b

Please sign in to comment.