X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frtdv3.sh;h=08f98a2978dbee7d5fa05ed43f0699df11bf8983;hb=b0de8e76ba8c4e2cacbef206d7864e856b1ffc1d;hp=29808afaf433b5ee8f9de0db3c9b7693e2a70d84;hpb=026509df164f628deb0f4660a172cca364ff58ae;p=releng%2Fglobal-jjb.git diff --git a/shell/rtdv3.sh b/shell/rtdv3.sh index 29808afa..08f98a29 100644 --- a/shell/rtdv3.sh +++ b/shell/rtdv3.sh @@ -11,6 +11,25 @@ echo "---> rtdv3.sh" set -euo pipefail +watchbuild(){ + echo "INFO: Running build against branch $1" + local buildid + local result + buildid=$(lftools rtd project-build-trigger "$rtdproject" "$1" | jq '.build.id') + + result=null + while [[ "$result" == null ]]; do + sleep 10 + result=$(lftools rtd project-build-details "$rtdproject" "$buildid" | jq '.success') + echo "INFO Current result of running build $result" + if [[ $result == failed ]]; then + echo "INFO: read the docs build completed with status: $result" + exit 1 + fi + done + echo "INFO: read the docs build completed with status: $result" +} + project_dashed="${PROJECT////-}" umbrella=$(echo "$GERRIT_URL" | awk -F'.' '{print $2}') if [[ "$SILO" == "sandbox" ]]; then @@ -22,6 +41,15 @@ fi #MASTER_RTD_PROJECT as a global jenkins cnt masterproject="$umbrella-$MASTER_RTD_PROJECT" +#Exceptions needed for onap, due to importing their old docs. +if [[ $masterproject == "onap-doc" ]]; then + masterproject="onap" +fi +if [[ $rtdproject == "onap-doc" ]]; then + rtdproject="onap" +fi + + echo "INFO:" echo "INFO: Project: $PROJECT" echo "INFO: Read the Docs Sub Project: https://$rtdproject.readthedocs.io" @@ -102,12 +130,31 @@ echo "INFO: Performing merge action" lftools rtd project-update "$rtdproject" default_version="$default_version" fi - lftools rtd project-build-trigger "$rtdproject" "$GERRIT_BRANCH" if [[ $GERRIT_BRANCH == "master" ]]; then - echo "INFO: triggering latest" - lftools rtd project-build-trigger "$rtdproject" latest + echo "INFO: triggering $rtdproject latest" + watchbuild latest else - echo "INFO: triggering stable" - lftools rtd project-build-trigger "$rtdproject" stable + + #read the docs only understands lower case branch names + branch=$(echo "$GERRIT_BRANCH" | tr '[:upper:]' '[:lower:]') + echo "INFO: Checking if read the docs has seen branch $branch" + + #if this is 200 "null" Then run discover branch + if [[ $(lftools rtd project-version-details "$rtdproject" "$branch" | jq '.active') == "null" ]]; then + echo "INFO: read the docs has not seen branch $branch for project $rtdproject" + echo "INFO: triggering $rtdproject latest to instantiate new branch discovery" + watchbuild latest + fi + + echo "INFO: triggering $rtdproject $branch" + watchbuild "$branch" + + #Make newly discovered branches visible in the u/i + isactive=$(lftools rtd project-version-details "$rtdproject" "$branch" | jq '.active') + if [[ "$isactive" == false ]]; then + echo "INFO: Marking $branch as active for project $rtdproject" + lftools rtd project-version-update "$rtdproject" "$branch" true + fi + fi fi