diff --git a/ci-job-validation.groovy b/ci-job-validation.groovy index 7e7f062d3..6c861d637 100644 --- a/ci-job-validation.groovy +++ b/ci-job-validation.groovy @@ -3,6 +3,7 @@ def cico_retry_interval = 60 def ci_git_repo = 'https://github.com/ceph/ceph-csi' def ci_git_branch = 'ci/centos' def ref = 'ci/centos' +def base = '' node('cico-workspace') { stage('checkout ci repository') { @@ -32,8 +33,11 @@ node('cico-workspace') { if (params.ghprbPullId != null) { ref = "pull/${ghprbPullId}/head" } + if (params.ghprbTargetBranch != null) { + base = "--base=${ghprbTargetBranch}" + } sh 'scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ./prepare.sh root@${CICO_NODE}:' - sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} ./prepare.sh --workdir=/opt/build/go/src/github.com/ceph/ceph-csi --gitrepo=${ci_git_repo} --ref=${ref}" + sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} ./prepare.sh --workdir=/opt/build/go/src/github.com/ceph/ceph-csi --gitrepo=${ci_git_repo} --ref=${ref} ${base}" } stage('test') { sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} "cd /opt/build/go/src/github.com/ceph/ceph-csi && make"' diff --git a/prepare.sh b/prepare.sh index 55ee64094..419456726 100755 --- a/prepare.sh +++ b/prepare.sh @@ -6,11 +6,13 @@ set -e -o pipefail gitrepo="https://github.com/ceph/ceph-csi" workdir="tip/" ref="master" +base="master" ARGUMENT_LIST=( "ref" "workdir" "gitrepo" + "base" ) opts=$(getopt \ @@ -38,6 +40,7 @@ while true; do echo "--ref specify the reference of pr" echo "--workdir specify the working directory" echo "--gitrepo specify the git repository" + echo "--base specify the base branch to checkout" echo " " echo "Sample Usage:" echo "./prepare.sh --gitrepo=https://github.com/example --workdir=/opt/build --ref=pull/123/head" @@ -56,6 +59,10 @@ while true; do ref=${1} echo "${ref}" ;; + --base) + shift + base=${1} + ;; --) shift break @@ -68,7 +75,7 @@ set -x yum -y install git podman -git clone --depth=1 "${gitrepo}" "${workdir}" +git clone --depth=1 --branch="${base}" "${gitrepo}" "${workdir}" cd "${workdir}" -git fetch --depth=1 origin "${ref}:tip/${ref}" +git fetch origin "${ref}:tip/${ref}" git checkout "tip/${ref}"