X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frtdv3.sh;h=29808afaf433b5ee8f9de0db3c9b7693e2a70d84;hb=576208dc964434966f301c635473529ac0a3103e;hp=c1014f4629694ccf00349cde68e6355ee7794818;hpb=718fdb52ab8a23a16e91f80a7d8ae26d116ca6ea;p=releng%2Fglobal-jjb.git diff --git a/shell/rtdv3.sh b/shell/rtdv3.sh index c1014f46..29808afa 100644 --- a/shell/rtdv3.sh +++ b/shell/rtdv3.sh @@ -12,7 +12,7 @@ echo "---> rtdv3.sh" set -euo pipefail project_dashed="${PROJECT////-}" -umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')" +umbrella=$(echo "$GERRIT_URL" | awk -F'.' '{print $2}') if [[ "$SILO" == "sandbox" ]]; then rtdproject="$umbrella-$project_dashed-test" else @@ -24,8 +24,8 @@ masterproject="$umbrella-$MASTER_RTD_PROJECT" echo "INFO:" echo "INFO: Project: $PROJECT" -echo "INFO: Read the Docs Project: https://$rtdproject.readthedocs.io" -echo "INFO: Read the Docs master Project: https://$masterproject.readthedocs.io" +echo "INFO: Read the Docs Sub Project: https://$rtdproject.readthedocs.io" +echo "INFO: Read the Docs Master Project: https://$masterproject.readthedocs.io" if [[ "$JOB_NAME" =~ "verify" ]]; then @@ -38,7 +38,7 @@ echo "INFO: Verify job completed" fi if [[ "$JOB_NAME" =~ "merge" ]]; then -echo "INFO: Running merge job" +echo "INFO: Performing merge action" # This retuns null if project exists. project_exists=false @@ -69,21 +69,45 @@ echo "INFO: Running merge job" if [[ "$rtdproject" != "$masterproject" ]]; then subproject_exists=false while read -r subproject; do - if [[ "$subproject" == "$rtdproject" ]]; then - subproject_exists=true - break - fi + if [[ "$subproject" == "$rtdproject" ]]; then + subproject_exists=true + break + fi done < <(lftools rtd subproject-list "$masterproject") if $subproject_exists; then - echo "INFO: subproject relationship already created" + echo "INFO: subproject $rtdproject relationship already created" else - echo "INFO: Need to create subproject relationship" + echo "INFO: Creating subproject relationship" lftools rtd subproject-create "$masterproject" "$rtdproject" echo "INFO sleeping for 10 seconds" sleep 10 fi fi - lftools rtd project-build-trigger "$rtdproject" "$STREAM" + # api v3 method does not update /latest/ when master is triggered. + # Also, when we build anything other than master we want to trigger /stable/ as well. + # allow projects to change their landing page from latest to branch_name + + current_version="$(lftools rtd project-details "$rtdproject" | yq -r .default_version)" + if [[ -z ${DEFAULT_VERSION:-} ]]; then + echo "DEFAULT_VERSION (default-version) value cannot be empty" + exit 1 + fi + default_version="${DEFAULT_VERSION}" + + echo "INFO: current default version $current_version" + if [[ $current_version != "$default_version" ]]; then + echo "INFO: Setting rtd landing page to $default_version" + 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 + else + echo "INFO: triggering stable" + lftools rtd project-build-trigger "$rtdproject" stable + fi fi