2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
14 project_dashed="${PROJECT////-}"
15 umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')"
16 if [[ "$SILO" == "sandbox" ]]; then
17 rtdproject="$umbrella-$project_dashed-test"
19 rtdproject="$umbrella-$project_dashed"
22 #MASTER_RTD_PROJECT as a global jenkins cnt
23 masterproject="$umbrella-$MASTER_RTD_PROJECT"
26 echo "INFO: Project: $PROJECT"
27 echo "INFO: Read the Docs Project: https://$rtdproject.readthedocs.io"
28 echo "INFO: Read the Docs master Project: https://$masterproject.readthedocs.io"
31 if [[ "$JOB_NAME" =~ "verify" ]]; then
32 if [[ "$(lftools rtd project-details "$rtdproject" | yq -r '.detail')" == "Not found." ]]; then
33 echo "INFO: Project not found, merge will create project https://$rtdproject.readthedocs.io"
36 echo "INFO: Verify job completed"
40 if [[ "$JOB_NAME" =~ "merge" ]]; then
41 echo "INFO: Running merge job"
43 # This retuns null if project exists.
48 while [[ $project_exists == "false" ]]; do
49 if [[ "$(lftools rtd project-details "$rtdproject" | yq -r '.detail')" == "Not found." ]]; then
50 echo "INFO: Project not found"
51 if [[ $project_created == "false" ]]; then
52 echo "INFO: Creating project https://$rtdproject.readthedocs.io"
53 lftools rtd project-create "$rtdproject" "$GERRIT_URL/$PROJECT" git "https://$rtdproject.readthedocs.io" py en
54 project_created="true"
56 echo "INFO sleeping for 30 seconds $cnt times"
59 if (( cnt >= 20 )); then
60 echo "INFO: Job has timed out"
64 echo "INFO: Project exists in read the docs as https://$rtdproject.readthedocs.io"
69 if [[ "$rtdproject" != "$masterproject" ]]; then
70 subproject_exists=false
71 while read -r subproject; do
72 if [[ "$subproject" == "$rtdproject" ]]; then
73 subproject_exists=true
76 done < <(lftools rtd subproject-list "$masterproject")
78 if $subproject_exists; then
79 echo "INFO: subproject relationship already created"
81 echo "INFO: Need to create subproject relationship"
82 lftools rtd subproject-create "$masterproject" "$rtdproject"
83 echo "INFO sleeping for 10 seconds"
88 # api v3 method does not update latest whith stream.
89 lftools rtd project-build-trigger "$rtdproject" "$STREAM"
90 lftools rtd project-build-trigger "$rtdproject" latest