From e690a73633773f2135b0d61c4ae174961523d90e Mon Sep 17 00:00:00 2001 From: Philip Cho Date: Wed, 17 Apr 2019 05:03:33 -0700 Subject: [PATCH] More reliable way to get git branch name --- Jenkinsfile | 20 ++++---------------- tests/ci_build/build_jvm_doc.sh | 8 ++++---- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0259cb9046b5..ead1338af688 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -131,14 +131,10 @@ def SphinxDoc() { node('linux && cpu') { unstash name: 'srcs' echo "Running sphinx-doc..." - def branch_name = sh ( - script: 'git rev-parse --abbrev-ref HEAD', - returnStdout: true - ).trim() //container_type = "lint" //docker_binary = "docker" //sh """#!/bin/bash - //CI_DOCKER_EXTRA_PARAMS_INIT='-e SPHINX_GIT_BRANCH=${args.branch_name}' ${dockerRun} ${container_type} ${docker_binary} make -C doc html + //CI_DOCKER_EXTRA_PARAMS_INIT='-e SPHINX_GIT_BRANCH=${BRANCH_NAME}' ${dockerRun} ${container_type} ${docker_binary} make -C doc html //""" } } @@ -183,24 +179,16 @@ def BuildJVMSpark(args) { def BuildJVMDoc() { node('linux && cpu') { unstash name: 'srcs' - def commit_id = sh ( - script: 'git rev-parse HEAD', - returnStdout: true - ).trim() - def branch_name = sh ( - script: 'git rev-parse --abbrev-ref HEAD', - returnStdout: true - ).trim() echo "Building JVM doc..." container_type = "jvm" docker_binary = "docker" s3Download file: 'tests/ci_build/maven-repo-cache.tar.bz2', bucket: 'xgboost-ci-jenkins-artifacts', force: true, path: 'maven-repo-cache.tar.bz2' sh """ - ${dockerRun} ${container_type} ${docker_binary} tests/ci_build/build_jvm_doc.sh ${commit_id} + ${dockerRun} ${container_type} ${docker_binary} tests/ci_build/build_jvm_doc.sh ${BRANCH_NAME} """ - archiveArtifacts artifacts: "jvm-packages/${commit_id}.tar.bz2", allowEmptyArchive: true + archiveArtifacts artifacts: "jvm-packages/${BRANCH_NAME}.tar.bz2", allowEmptyArchive: true echo 'Deploying doc...' - s3Upload file: "jvm-packages/${commit_id}.tar.bz2", bucket: 'xgboost-docs', acl: 'PublicRead', path: "${branch_name}.tar.bz2" + s3Upload file: "jvm-packages/${BRANCH_NAME}.tar.bz2", bucket: 'xgboost-docs', acl: 'PublicRead', path: "${BRANCH_NAME}.tar.bz2" } } diff --git a/tests/ci_build/build_jvm_doc.sh b/tests/ci_build/build_jvm_doc.sh index 7890c4a34008..d17e7345df87 100755 --- a/tests/ci_build/build_jvm_doc.sh +++ b/tests/ci_build/build_jvm_doc.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Usage: $0 [commit id]" + echo "Usage: $0 [branch name]" exit 1 fi @@ -13,7 +13,7 @@ set -x cd jvm-packages -commit_id=$1 +branch_name=$1 # Install JVM packages in local Maven repository mvn install -DskipTests @@ -30,8 +30,8 @@ cp -rv xgboost4j-spark/target/site/scaladocs/ ./tmp/scaladocs/xgboost4j-spark/ cp -rv xgboost4j-flink/target/site/scaladocs/ ./tmp/scaladocs/xgboost4j-flink/ cd tmp -tar cvjf ${commit_id}.tar.bz2 javadocs/ scaladocs/ -mv ${commit_id}.tar.bz2 .. +tar cvjf ${branch_name}.tar.bz2 javadocs/ scaladocs/ +mv ${branch_name}.tar.bz2 .. cd .. rm -rfv tmp/