5 export PATH=$PATH:/usr/local/bin/
8 if [[ -d docs/output ]]; then
10 echo "cleaning up output directory"
14 trap clean EXIT TERM INT SIGTERM SIGHUP
17 while read -d $'\n'; do
18 directories+=("$REPLY")
19 done < <(find docs/ -name 'index.rst' -printf '%h\n' | sort -u )
21 for dir in "${{directories[@]}}"; do
23 echo "#############################"
24 echo "Building DOCS in ${{dir##*/}}"
25 echo "#############################"
28 if [[ ! -d docs/output/"${{dir##*/}}/" ]]; then
29 mkdir -p docs/output/"${{dir##*/}}/"
32 sphinx-build -b html -E -c docs/etc/ ""$dir"/" docs/output/"${{dir##*/}}/"
35 # NOTE: make sure source parameters for GS paths are not empty.
36 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
37 [[ $GERRIT_PROJECT =~ .+ ]]
38 [[ $GERRIT_BRANCH =~ .+ ]]
39 gs_path_review="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
41 for dir in "${{directories[@]}}"; do
43 echo "#############################"
44 echo "UPLOADING DOCS in ${{dir##*/}}"
45 echo "#############################"
48 if [[ $GERRIT_BRANCH = "master" ]] ; then
49 gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT"
51 gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT/${{GERRIT_BRANCH##*/}}"
54 if [[ $JOB_NAME =~ "verify" ]] ; then
55 gsutil cp -r docs/output/"${{dir##*/}}/" "gs://$gs_path_review/"
56 # post link to gerrit as comment
57 gerrit_comment="$(echo '"Document is available at 'http://$gs_path_review/"${{dir##*/}}"/index.html' for review"')"
58 echo "$gerrit_comment"
59 ssh -p 29418 gerrit.opnfv.org gerrit review -p $GERRIT_PROJECT -m \
60 "$gerrit_comment" $GERRIT_PATCHSET_REVISION
64 gsutil cp -r docs/output/"${{dir##*/}}/" "gs://$gs_path_branch/"
65 echo "Latest document is available at http://$gs_path_branch/index.html"
67 #Clean up review when merging
68 if gsutil ls "gs://$gs_path_review" > /dev/null 2>&1 ; then
70 echo "Deleting Out-of-dated Documents..."
71 gsutil rm -r "gs://$gs_path_review"