mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-18 02:39:30 +00:00
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:
parent
1700f8585c
commit
c281511a11
@ -25,7 +25,7 @@ objects:
|
|||||||
image: image-registry.openshift-image-registry.svc:5000/ceph-csi/jjb:latest
|
image: image-registry.openshift-image-registry.svc:5000/ceph-csi/jjb:latest
|
||||||
env:
|
env:
|
||||||
- name: GIT_REPO
|
- name: GIT_REPO
|
||||||
value: https://github.com/ceph/ceph-csi
|
value: "${GIT_REPO}"
|
||||||
- name: GIT_REF
|
- name: GIT_REF
|
||||||
value: "${GIT_REF}"
|
value: "${GIT_REF}"
|
||||||
- name: MAKE_TARGET
|
- name: MAKE_TARGET
|
||||||
@ -47,3 +47,7 @@ parameters:
|
|||||||
description: the git branch or other ref to checkout and deploy
|
description: the git branch or other ref to checkout and deploy
|
||||||
value: ci/centos
|
value: ci/centos
|
||||||
required: false
|
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
|
||||||
|
@ -25,7 +25,7 @@ objects:
|
|||||||
image: image-registry.openshift-image-registry.svc:5000/ceph-csi/jjb:latest
|
image: image-registry.openshift-image-registry.svc:5000/ceph-csi/jjb:latest
|
||||||
env:
|
env:
|
||||||
- name: GIT_REPO
|
- name: GIT_REPO
|
||||||
value: https://github.com/ceph/ceph-csi
|
value: "${GIT_REPO}"
|
||||||
- name: GIT_REF
|
- name: GIT_REF
|
||||||
value: "${GIT_REF}"
|
value: "${GIT_REF}"
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
@ -37,3 +37,7 @@ parameters:
|
|||||||
description: the git branch or other ref to checkout and validate
|
description: the git branch or other ref to checkout and validate
|
||||||
value: ci/centos
|
value: ci/centos
|
||||||
required: false
|
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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Create a new Job in OCP that runs the jbb-validate container once. This
|
# 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
|
# 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
|
# 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="ci/centos"
|
||||||
GIT_REF=${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() {
|
get_pod_status() {
|
||||||
oc get "pod/${1}" --no-headers -o=jsonpath='{.status.phase}'
|
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
|
# make sure there is a valid OCP session
|
||||||
oc version
|
oc version
|
||||||
|
|
||||||
@ -40,8 +87,8 @@ cd "$(dirname "${0}")"
|
|||||||
# unique ID for the session
|
# unique ID for the session
|
||||||
SESSION=$(uuidgen)
|
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}" -p=GIT_REPO="${GIT_REPO}"
|
||||||
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 create -f -
|
||||||
|
|
||||||
# loop until pod is available
|
# loop until pod is available
|
||||||
while true
|
while true
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
name: jjb-deploy
|
name: jjb-deploy
|
||||||
project-type: pipeline
|
project-type: pipeline
|
||||||
concurrent: false
|
concurrent: false
|
||||||
|
parameters:
|
||||||
|
- string:
|
||||||
|
name: GIT_REPO
|
||||||
|
default: http://github.com/ceph/ceph-csi
|
||||||
|
description: The git repo url
|
||||||
|
- string:
|
||||||
|
name: GIT_BRANCH
|
||||||
|
default: ci/centos
|
||||||
|
description: The git branch
|
||||||
properties:
|
properties:
|
||||||
- github:
|
- github:
|
||||||
url: https://github.com/ceph/ceph-csi
|
url: https://github.com/ceph/ceph-csi
|
||||||
@ -10,22 +19,21 @@
|
|||||||
days-to-keep: 7
|
days-to-keep: 7
|
||||||
artifact-days-to-keep: 7
|
artifact-days-to-keep: 7
|
||||||
dsl: |
|
dsl: |
|
||||||
def GIT_REPO = 'http://github.com/ceph/ceph-csi'
|
|
||||||
def GIT_BRANCH = 'ci/centos'
|
|
||||||
node {
|
node {
|
||||||
stage('checkout ci repository') {
|
stage('checkout ci repository') {
|
||||||
git url: "${GIT_REPO}", branch: "${GIT_BRANCH}", changelog: false
|
git url: "${GIT_REPO}", branch: "${GIT_BRANCH}", changelog: false
|
||||||
}
|
}
|
||||||
stage('deployment') {
|
stage('deployment') {
|
||||||
sh './deploy/jjb.sh deploy'
|
sh "./deploy/jjb.sh --cmd deploy \
|
||||||
|
--GIT_REF ${GIT_BRANCH} --GIT_REPO ${GIT_REPO}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scm:
|
scm:
|
||||||
- git:
|
- git:
|
||||||
name: origin
|
name: origin
|
||||||
url: https://github.com/ceph/ceph-csi
|
url: $GIT_REPO
|
||||||
branches:
|
branches:
|
||||||
- ci/centos
|
- $GIT_BRANCH
|
||||||
triggers:
|
triggers:
|
||||||
- pollscm:
|
- pollscm:
|
||||||
cron: "H/5 * * * *"
|
cron: "H/5 * * * *"
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
name: jjb-validate
|
name: jjb-validate
|
||||||
project-type: pipeline
|
project-type: pipeline
|
||||||
concurrent: false
|
concurrent: false
|
||||||
|
parameters:
|
||||||
|
- string:
|
||||||
|
name: GIT_REPO
|
||||||
|
default: http://github.com/ceph/ceph-csi
|
||||||
|
description: The git repo url
|
||||||
|
- string:
|
||||||
|
name: GIT_BRANCH
|
||||||
|
default: ci/centos
|
||||||
|
description: The git branch
|
||||||
properties:
|
properties:
|
||||||
- github:
|
- github:
|
||||||
url: https://github.com/ceph/ceph-csi
|
url: https://github.com/ceph/ceph-csi
|
||||||
@ -10,9 +19,6 @@
|
|||||||
days-to-keep: 7
|
days-to-keep: 7
|
||||||
artifact-days-to-keep: 7
|
artifact-days-to-keep: 7
|
||||||
dsl: |
|
dsl: |
|
||||||
def GIT_REPO = 'https://github.com/ceph/ceph-csi'
|
|
||||||
def GIT_BRANCH = 'ci/centos'
|
|
||||||
|
|
||||||
if (params.ghprbPullId != null) {
|
if (params.ghprbPullId != null) {
|
||||||
GIT_BRANCH = "pull/${ghprbPullId}/merge"
|
GIT_BRANCH = "pull/${ghprbPullId}/merge"
|
||||||
}
|
}
|
||||||
@ -24,13 +30,14 @@
|
|||||||
refspec: "${GIT_BRANCH}"]]])
|
refspec: "${GIT_BRANCH}"]]])
|
||||||
}
|
}
|
||||||
stage('validation') {
|
stage('validation') {
|
||||||
sh "GIT_REF=${GIT_BRANCH} ./deploy/jjb.sh validate"
|
sh "./deploy/jjb.sh --cmd validate \
|
||||||
|
--GIT_REF ${GIT_BRANCH} --GIT_REPO ${GIT_REPO}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triggers:
|
triggers:
|
||||||
- github-pull-request:
|
- github-pull-request:
|
||||||
status-context: ci/centos/jjb-validate
|
status-context: ci/centos/jjb-validate
|
||||||
trigger-phrase: '/(re)?test ((all)|(ci/centos/jjb-validate))'
|
trigger-phrase: "/(re)?test ((all)|(ci/centos/jjb-validate))"
|
||||||
permit-all: true
|
permit-all: true
|
||||||
github-hooks: true
|
github-hooks: true
|
||||||
white-list-target-branches:
|
white-list-target-branches:
|
||||||
|
Loading…
Reference in New Issue
Block a user