mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-18 10:49:30 +00:00
ci: add --base=<branch> to checkout a base branch
When checking out a PR for a non-master branch, `git clone` should download the last commit of the branch. Adding a `--base=..` option to pass the cloning of a selected branch, instead of `master`. We also want to fetch all commits in the PR, so they can get tested with `commitlint`. Only fetch --depth=1 the initial clone, but fetch everything in the PR itself. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
b6b517deb2
commit
6e3c1dadae
@ -3,6 +3,7 @@ def cico_retry_interval = 60
|
|||||||
def ci_git_repo = 'https://github.com/ceph/ceph-csi'
|
def ci_git_repo = 'https://github.com/ceph/ceph-csi'
|
||||||
def ci_git_branch = 'ci/centos'
|
def ci_git_branch = 'ci/centos'
|
||||||
def ref = 'ci/centos'
|
def ref = 'ci/centos'
|
||||||
|
def base = ''
|
||||||
|
|
||||||
node('cico-workspace') {
|
node('cico-workspace') {
|
||||||
stage('checkout ci repository') {
|
stage('checkout ci repository') {
|
||||||
@ -32,8 +33,11 @@ node('cico-workspace') {
|
|||||||
if (params.ghprbPullId != null) {
|
if (params.ghprbPullId != null) {
|
||||||
ref = "pull/${ghprbPullId}/head"
|
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 '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') {
|
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"'
|
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} "cd /opt/build/go/src/github.com/ceph/ceph-csi && make"'
|
||||||
|
11
prepare.sh
11
prepare.sh
@ -6,11 +6,13 @@ set -e -o pipefail
|
|||||||
gitrepo="https://github.com/ceph/ceph-csi"
|
gitrepo="https://github.com/ceph/ceph-csi"
|
||||||
workdir="tip/"
|
workdir="tip/"
|
||||||
ref="master"
|
ref="master"
|
||||||
|
base="master"
|
||||||
|
|
||||||
ARGUMENT_LIST=(
|
ARGUMENT_LIST=(
|
||||||
"ref"
|
"ref"
|
||||||
"workdir"
|
"workdir"
|
||||||
"gitrepo"
|
"gitrepo"
|
||||||
|
"base"
|
||||||
)
|
)
|
||||||
|
|
||||||
opts=$(getopt \
|
opts=$(getopt \
|
||||||
@ -38,6 +40,7 @@ while true; do
|
|||||||
echo "--ref specify the reference of pr"
|
echo "--ref specify the reference of pr"
|
||||||
echo "--workdir specify the working directory"
|
echo "--workdir specify the working directory"
|
||||||
echo "--gitrepo specify the git repository"
|
echo "--gitrepo specify the git repository"
|
||||||
|
echo "--base specify the base branch to checkout"
|
||||||
echo " "
|
echo " "
|
||||||
echo "Sample Usage:"
|
echo "Sample Usage:"
|
||||||
echo "./prepare.sh --gitrepo=https://github.com/example --workdir=/opt/build --ref=pull/123/head"
|
echo "./prepare.sh --gitrepo=https://github.com/example --workdir=/opt/build --ref=pull/123/head"
|
||||||
@ -56,6 +59,10 @@ while true; do
|
|||||||
ref=${1}
|
ref=${1}
|
||||||
echo "${ref}"
|
echo "${ref}"
|
||||||
;;
|
;;
|
||||||
|
--base)
|
||||||
|
shift
|
||||||
|
base=${1}
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -68,7 +75,7 @@ set -x
|
|||||||
|
|
||||||
yum -y install git podman
|
yum -y install git podman
|
||||||
|
|
||||||
git clone --depth=1 "${gitrepo}" "${workdir}"
|
git clone --depth=1 --branch="${base}" "${gitrepo}" "${workdir}"
|
||||||
cd "${workdir}"
|
cd "${workdir}"
|
||||||
git fetch --depth=1 origin "${ref}:tip/${ref}"
|
git fetch origin "${ref}:tip/${ref}"
|
||||||
git checkout "tip/${ref}"
|
git checkout "tip/${ref}"
|
||||||
|
Loading…
Reference in New Issue
Block a user