ci: Add the ability to run JJB from private branch/fork

Add the ability to run JJB from private branch/fork

jjb-deploy.yaml:
- Add GIT_REPO parameter (not required) with default value

jjb.sh:
- Changing PS4 for more indicative debug prompt
- Adding flags to get the repo and branch

jjb-deploy.yaml:
- Calling the jjb.sh with the correct flags

Signed-off-by: liranmauda <liran.mauda@gmail.com>
This commit is contained in:
liranmauda
2020-11-01 13:31:05 +02:00
committed by mergify[bot]
parent 1700f8585c
commit c281511a11
5 changed files with 99 additions and 29 deletions

View File

@ -25,7 +25,7 @@ objects:
image: image-registry.openshift-image-registry.svc:5000/ceph-csi/jjb:latest
env:
- name: GIT_REPO
value: https://github.com/ceph/ceph-csi
value: "${GIT_REPO}"
- name: GIT_REF
value: "${GIT_REF}"
- name: MAKE_TARGET
@ -47,3 +47,7 @@ parameters:
description: the git branch or other ref to checkout and deploy
value: ci/centos
required: false
- name: GIT_REPO
description: the git repo or other fork to checkout and deploy
value: https://github.com/ceph/ceph-csi
required: false

View File

@ -25,7 +25,7 @@ objects:
image: image-registry.openshift-image-registry.svc:5000/ceph-csi/jjb:latest
env:
- name: GIT_REPO
value: https://github.com/ceph/ceph-csi
value: "${GIT_REPO}"
- name: GIT_REF
value: "${GIT_REF}"
restartPolicy: Never
@ -37,3 +37,7 @@ parameters:
description: the git branch or other ref to checkout and validate
value: ci/centos
required: false
- name: GIT_REPO
description: the git repo or other fork to checkout and validate
value: https://github.com/ceph/ceph-csi
required: false

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Create a new Job in OCP that runs the jbb-validate container once. This
# script will wait for completion of the validation, and uses the result of the
@ -11,26 +11,73 @@
#
# error out in case a command fails
set -e
export PS4='\e[32m+ ${FUNCNAME:-main}@${BASH_SOURCE}:${LINENO} \e[0m'
set -ex
CMD="${1}"
GIT_REF=${GIT_REF:-"ci/centos"}
GIT_REF="ci/centos"
GIT_REPO="https://github.com/ceph/ceph-csi"
function usage() {
echo "Options:"
echo "--cmd the mode of this script. can be validate or deploy"
echo "--GIT_REF specify the branch to build from (default: ${GIT_REF})"
echo "--GIT_REPO specify the repo to build from (default: ${GIT_REPO})"
echo "--help specify the flags"
echo " "
exit 0
}
ARGUMENT_LIST=(
"cmd"
"GIT_REF"
"GIT_REPO"
)
opts=$(getopt \
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")help" \
--name "$(basename "${0}")" \
--options "" \
-- "$@"
)
rc=$?
if [ ${rc} -ne 0 ]
then
echo "Try '--help' for more information."
exit 1
fi
eval set -- "${opts}"
while true; do
case "${1}" in
--cmd) CMD=${2}
shift 2
if [ "${CMD}" != "deploy" ] && [ "${CMD}" != "validate" ]
then
echo "no such command: ${CMD}"
exit 1
fi ;;
--GIT_REF) GIT_REF=${2}
shift 2 ;;
--GIT_REPO) GIT_REPO=${2}
shift 2 ;;
--help) usage ;;
--) shift 1
break ;;
esac
done
if [ -z "${CMD}" ]
then
echo "missing --cmd <command>."
usage
fi
get_pod_status() {
oc get "pod/${1}" --no-headers -o=jsonpath='{.status.phase}'
}
case "${CMD}" in
"validate")
;;
"deploy")
;;
*)
echo "no such command: ${CMD}"
exit 1
;;
esac
# make sure there is a valid OCP session
oc version
@ -40,8 +87,8 @@ cd "$(dirname "${0}")"
# unique ID for the session
SESSION=$(uuidgen)
oc process -f "jjb-${CMD}.yaml" -p=SESSION="${SESSION}" -p=GIT_REF="${GIT_REF}"
oc process -f "jjb-${CMD}.yaml" -p=SESSION="${SESSION}" -p=GIT_REF="${GIT_REF}" | oc create -f -
oc process -f "jjb-${CMD}.yaml" -p=SESSION="${SESSION}" -p=GIT_REF="${GIT_REF}" -p=GIT_REPO="${GIT_REPO}"
oc process -f "jjb-${CMD}.yaml" -p=SESSION="${SESSION}" -p=GIT_REF="${GIT_REF}" -p=GIT_REPO="${GIT_REPO}" | oc create -f -
# loop until pod is available
while true