Fix all the ugly formatting that I left in due to end of day fatigue.
[releng.git] / jjb / copper / docu-build.sh
1 #!/bin/bash
2 set -e
3 set -o pipefail
4
5 export PATH=$PATH:/usr/local/bin/
6
7 echo
8 echo "Build"
9 echo "-----"
10 echo
11
12 #make
13 sphinx-build -b html -E -c etc/ design_docs/ build/
14
15 echo
16 echo "Upload"
17 echo "------"
18 echo
19
20 # NOTE: make sure source parameters for GS paths are not empty.
21 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
22 [[ $GERRIT_PROJECT =~ .+ ]]
23 [[ $GERRIT_BRANCH =~ .+ ]]
24
25 gs_path_review="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
26 if [[ $GERRIT_BRANCH = "master" ]] ; then
27     gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT"
28 else
29     gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT/${{GERRIT_BRANCH##*/}}"
30 fi
31
32 if [[ $JOB_NAME =~ "verify" ]] ; then
33     gsutil cp -r build/* "gs://$gs_path_review/"
34     echo
35     echo "Document is available at http://$gs_path_review/index.html"
36     # post link to gerrit as comment
37     gerrit_comment=$(echo '"Document is available at 'http://$gs_path_review/index.html' for review"')
38     ssh -p 29418 gerrit.opnfv.org gerrit review -p $GERRIT_PROJECT -m \
39     $gerrit_comment $GERRIT_PATCHSET_REVISION
40 else
41     gsutil cp -r build/* "gs://$gs_path_branch/design_docs/"
42     #gsutil cp -r build/design_docs "gs://$gs_path_branch/"
43     #gsutil cp -r build/requirements/html "gs://$gs_path_branch/"
44     #gsutil cp -r build/requirements/latex/*.pdf "gs://$gs_path_branch/"
45     #echo
46
47     echo "Latest document is available at http://$gs_path_branch/design_docs/index.html"
48
49     if gsutil ls "gs://$gs_path_review" > /dev/null 2>&1 ; then
50         echo
51         echo "Deleting Out-of-dated Documents..."
52         gsutil rm -r "gs://$gs_path_review"
53     fi
54 fi