aafcb2f664427b739b9e79139131e39c8ab72660
[releng.git] / 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
14 echo
15 echo "Upload"
16 echo "------"
17 echo
18
19 # NOTE: make sure source parameters for GS paths are not empty.
20 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
21 [[ $GERRIT_PROJECT =~ .+ ]]
22 [[ $GERRIT_BRANCH =~ .+ ]]
23
24 gs_path_review="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
25 if [[ $GERRIT_BRANCH = "master" ]] ; then
26     gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT"
27 else
28     gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT/${{GERRIT_BRANCH##*/}}"
29 fi
30
31 if [[ $JOB_NAME =~ "verify" ]] ; then
32     gsutil cp -r build/* "gs://$gs_path_review/"
33     echo
34     echo "Document is available at http://$gs_path_review"
35 else
36     gsutil cp -r build/requirements/latex/*.pdf "gs://$gs_path_branch/"
37     echo
38     echo "Document is available at http://$gs_path_branch"
39 fi
40
41 if [[ $GERRIT_EVENT_TYPE = "change-merged" ]] ; then
42     echo
43     echo "Clean Out-of-dated Documents"
44     echo "----------------------------"
45     echo
46     gsutil rm -r "gs://$gs_path_review" || true
47 fi