- declare -i cnt=0
- while [[ $project_exists == "false" ]]; do
- if [[ "$(lftools rtd project-details "$rtdproject" | yq -r '.detail')" == "Not found." ]]; then
- echo "INFO: Project not found"
- if [[ $project_created == "false" ]]; then
- echo "INFO: Creating project https://$rtdproject.readthedocs.io"
- lftools rtd project-create "$rtdproject" "$GERRIT_URL/$PROJECT" git "https://$rtdproject.readthedocs.io" py en
- project_created="true"
+ declare -i cnt=0
+ while [[ $project_exists == "false" ]]; do
+ if [[ "$(lftools rtd project-details "$rtdproject" | yq -r '.detail')" == "Not found." ]]; then
+ echo "INFO: Project not found"
+ if [[ $project_created == "false" ]]; then
+ echo "INFO: Creating project https://$rtdproject.readthedocs.io"
+ lftools rtd project-create "$rtdproject" "$GERRIT_URL/$PROJECT" \
+ git "https://$rtdproject.readthedocs.io" py en
+ project_created="true"
+ fi
+ echo "INFO sleeping for 30 seconds $cnt times"
+ sleep 30
+ cnt=$((cnt+1))
+ if (( cnt >= 20 )); then
+ echo "INFO: Job has timed out"
+ exit 1
+ fi
+ else
+ echo "INFO: Project exists in read the docs as https://$rtdproject.readthedocs.io"
+ project_exists="true"
+ fi
+ done
+
+ if [[ "$rtdproject" != "$masterproject" ]]; then
+ subproject_exists=false
+ while read -r subproject; do
+ if [[ "$subproject" == "$rtdproject" ]]; then
+ subproject_exists=true
+ break
+ fi
+ done < <(lftools rtd subproject-list "$masterproject")
+
+ if $subproject_exists; then
+ echo "INFO: subproject $rtdproject relationship already created"
+ else
+ echo "INFO: Creating subproject relationship"
+ lftools rtd subproject-create "$masterproject" "$rtdproject"
+ echo "INFO sleeping for 10 seconds"
+ sleep 10