Skip to content

Commit

Permalink
FABN-1048 Update pipeline scripts
Browse files Browse the repository at this point in the history
Update Jenkinsfile to fetch the patchset on verify job
and clone the repository on merge job

Change-Id: I27f73c0a65d7ffcf74f1298e9c73c0f9be6a12fb
Signed-off-by: rameshthoomu <rameshbabu.thoomu@gmail.com>
  • Loading branch information
rameshthoomu committed Dec 4, 2018
1 parent 1d0d38f commit 790484d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
34 changes: 23 additions & 11 deletions Jenkinsfile.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,43 @@ node ('hyp-x') { // trigger build on x86_64 node
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:${nodeHome}/bin:$PATH"
def REFSPEC = sh(returnStdout: true, script: 'echo ${JOB_NAME} | grep "verify"').trim()
def failure_stage = "none"
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
try {
dir("${ROOTDIR}"){
if (REFSPEC != null) {
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']]])
} else {
// Clone fabric-sdk-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/$PROJECT") {
sh '''
[ -e gopath/src/github.com/hyperledger/fabric-sdk-node ] || mkdir -p $PROJECT_DIR
cd $PROJECT_DIR
# Clone fabric-sdk-node repository
git clone git://cloud.hyperledger.org/mirror/fabric-sdk-node && cd fabric-sdk-node
# Checkout to Branch and Apply patchset on latest commit
git checkout "$GERRIT_BRANCH" && git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
# Print last two commit details
echo "************"
echo
git log -n2 --pretty=oneline --abbrev-commit
echo "************"
echo
'''
}
}
catch (err) {
failure_stage = "Fetch patchset"
throw err
}
}
}
}
// clean environment and get env data
stage("Clean Environment - Get Env Info") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
Expand Down
37 changes: 24 additions & 13 deletions Jenkinsfile.z
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,44 @@ node('hyp-z') {
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"
def REFSPEC = sh(returnStdout: true, script: 'echo ${JOB_NAME} | grep "verify"').trim()
def failure_stage = "none"
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
cleanWs()
try {
dir("${ROOTDIR}"){
if (REFSPEC != null) {
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']]])
} else {
// Clone fabric-sdk-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/$PROJECT") {
sh '''
[ -e gopath/src/github.com/hyperledger/fabric-sdk-node ] || mkdir -p $PROJECT_DIR
cd $PROJECT_DIR
# Clone sdk-node repository
git clone git://cloud.hyperledger.org/mirror/fabric-sdk-node && cd fabric-sdk-node
# Checkout to Branch and Apply patchset on latest commit
git checkout $GERRIT_BRANCH && git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
# Print last two commit details
echo "***********"
echo
git log -n2 --pretty=oneline --abbrev-commit
echo "***********"
git checkout "$GERRIT_BRANCH" && git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
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']) {
Expand Down

0 comments on commit 790484d

Please sign in to comment.