Skip to content

Commit

Permalink
FABN-997 Add credentials in pipeline script
Browse files Browse the repository at this point in the history
Add NPM_TOKEN and API Docs credentials to publish
npm modules and also, remove rocketChat channel from
post script.

Change-Id: I0193bff54c7773658f60196b440c070787c4a671
Signed-off-by: rameshthoomu <[email protected]>
  • Loading branch information
rameshthoomu committed Nov 6, 2018
1 parent 970b53e commit 214b813
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
19 changes: 13 additions & 6 deletions Jenkinsfile.x
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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.VERSION = sh(returnStdout: true, script: 'curl -O https://raw.githubusercontent.com/hyperledger/fabric/master/Makefile && cat Makefile | grep "PREV_VERSION =" | cut -d "=" -f2').trim()
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.VERSION = "$VERSION" // BASE_VERSION from fabric Makefile
env.ARCH = "amd64"
env.IMAGE_TAG = "${ARCH}-${VERSION}-stable" // fabric latest stable version from nexus
Expand Down Expand Up @@ -117,18 +117,20 @@ if (env.GERRIT_EVENT_TYPE == "change-merged") {
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log'
if (env.GERRIT_EVENT_TYPE == 'change-merged') {
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
rocketSend channel: 'jenkins-robot', message: "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - (<${env.BUILD_URL}|Open>)"
rocketSend channel: "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - BUILD_URL: (<${env.BUILD_URL}|Open>)"
}
}
} // finally block end here
} // timestamps end here
} // node block end here

def publishNpm() {
def ROOTDIR = pwd()
// Publish npm modules after successful merge
stage("Publish npm Modules") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
def ROOTDIR = pwd()
withCredentials([[$class : 'StringBinding',
credentialsId: 'NPM_LOCAL',
variable : 'NPM_TOKEN']]) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --publish_NpmModules'
Expand All @@ -144,9 +146,13 @@ def ROOTDIR = pwd()
}

def apiDocs() {
def ROOTDIR = pwd()
// Publish SDK_NODE API docs after successful merge
stage("Publish API Docs") {
def ROOTDIR = pwd()
withCredentials([[$class : 'UsernamePasswordMultiBinding',
credentialsId: 'sdk-node-credentials',
usernameVariable: 'NODE_SDK_USERNAME',
passwordVariable: 'NODE_SDK_PASSWORD']]) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-sdk-node/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --publish_ApiDocs'
Expand All @@ -157,5 +163,6 @@ def ROOTDIR = pwd()
currentBuild.result = 'FAILURE'
throw err
}
}
}
}
}
9 changes: 5 additions & 4 deletions Jenkinsfile.z
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ node('hyp-z') {

def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>
env.NODE_VER = "8.11.3"
env.VERSION = sh(returnStdout: true, script: 'curl -O https://raw.githubusercontent.com/hyperledger/fabric/master/Makefile && cat Makefile | grep "PREV_VERSION =" | cut -d "=" -f2').trim()
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.VERSION = "$VERSION" // BASE_VERSION from fabric Makefile
env.ARCH = "s390x" // `uname -m`
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
Expand Down Expand Up @@ -54,6 +54,7 @@ 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'
Expand All @@ -65,7 +66,7 @@ node('hyp-z') {
throw err
}
}
}
}

// Pull fabric, fabric-ca Docker Images
stage("Pull Docker Images") {
Expand Down Expand Up @@ -102,7 +103,7 @@ node('hyp-z') {
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log'
if (env.GERRIT_EVENT_TYPE == 'change-merged') {
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
rocketSend channel: 'jenkins-robot', message: "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - (<${env.BUILD_URL}|Open>)"
rocketSend channel: "Build Notification - STATUS: ${currentBuild.result} - BRANCH: ${env.GERRIT_BRANCH} - PROJECT: ${env.PROJECT} - BUILD_URL: (<${env.BUILD_URL}|Open>)"
}
}
} // finally block end here
Expand Down
35 changes: 26 additions & 9 deletions scripts/Jenkins_Scripts/CI_Script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,34 @@ pull_Thirdparty_Images() {
}
# pull fabric, fabric-ca images from nexus
pull_Docker_Images() {
for IMAGES in peer orderer ca; do
for IMAGES in peer orderer ca javaenv; do
echo "-----------> pull $IMAGES image"
echo
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
if [ $IMAGES == "javaenv" ]; then
if [ $ARCH == "s390x" ]; then
# Do not pull javaenv if OS_VER == s390x
echo "-----------> skipping pull of javaenv image on s390x"
else
# Pull javaenv at same level as node SDK
echo "-----------> pull $ORG_NAME-$IMAGES:${ARCH}-${IMAGE_TAG} image"
echo
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
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 rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG}
fi
else
echo "-----------> pull $IMAGES image"
echo
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
fi
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 rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:${IMAGE_TAG}
done
echo
docker images | grep hyperledger/fabric
Expand Down

0 comments on commit 214b813

Please sign in to comment.