ffb131114f74a9b8d7b6e2417a6ce78af031647c
[releng.git] / jjb / genesis / 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/design_docs "gs://$gs_path_branch/"
37     gsutil cp -r build/requirements/html "gs://$gs_path_branch/"
38     gsutil cp -r build/requirements/latex/*.pdf "gs://$gs_path_branch/"
39     echo
40     echo "Latest document is available at http://$gs_path_branch"
41
42     if gsutil ls "gs://$gs_path_review" > /dev/null 2>&1 ; then
43         echo
44         echo "Deleting Out-of-dated Documents..."
45         gsutil rm -r "gs://$gs_path_review"
46     fi
47 fi