Bring docu generation up to date for genesis project 02/1102/1
authorAric Gardner <agardner@linuxfoundation.org>
Fri, 31 Jul 2015 21:00:55 +0000 (17:00 -0400)
committerAric Gardner <agardner@linuxfoundation.org>
Fri, 31 Jul 2015 21:00:55 +0000 (17:00 -0400)
Change-Id: Id7abeb3e01226d40722f0cc61a45465ce9a82682
Signed-off-by: Aric Gardner <agardner@linuxfoundation.org>
jjb/genesis/docu-build.sh
jjb/genesis/docu-verify.sh [deleted file]
jjb/genesis/genesis-docs.yml

index bf69c0c..ffb1311 100644 (file)
@@ -2,66 +2,46 @@
 set -e
 set -o pipefail
 
-project="$(git remote -v | head -n1 | awk '{{print $2}}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')"
 export PATH=$PATH:/usr/local/bin/
 
-git_sha1="$(git rev-parse HEAD)"
-docu_build_date="$(date)"
-
-files=()
-while read -r -d ''; do
-       files+=("$REPLY")
-done < <(find . -type f -iname '*.rst' -print0)
-
-for file in "${{files[@]}}"; do
-
-       file_cut="${{file%.*}}"
-       gs_cp_folder="$(echo "$file"| cut -d "/" -f2,3)"
-
-        # sed part
-        sed -i "s/_sha1_/$git_sha1/g" $file
-        sed -i "s/_date_/$docu_build_date/g" $file
-
-       # rst2html part
-       html_file=$file_cut".html"
-       echo "rst2html $file"
-       rst2html $file | gsutil cp -L gsoutput.txt - \
-       gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$html_file")
-       gsutil setmeta -h "Content-Type:text/html" \
-                       -h "Cache-Control:private, max-age=0, no-transform" \
-                       gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$html_file")
-       cat gsoutput.txt
-       rm -f gsoutput.txt
-
-       # rst2pdf part
-       pdf_file="$file_cut"".pdf"
-       echo "rst2pdf $file"
-       rst2pdf "$file" -o - | gsutil cp -L gsoutput.txt - \
-       gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$pdf_file")
-       gsutil setmeta -h "Content-Type:application/pdf" \
-                       -h "Cache-Control:private, max-age=0, no-transform" \
-                       gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$pdf_file")
-       cat gsoutput.txt
-       rm -f gsoutput.txt
-
-done
-
-images=()
-while read -r -d ''; do
-        images+=("$REPLY")
-done < <(find * -type f \( -iname \*.jpg -o -iname \*.png \) -print0)
-
-for img in "${{images[@]}}"; do
-
-        # uploading found images
-        echo "uploading $img"
-        cat "$img" | gsutil cp -L gsoutput.txt - \
-        gs://artifacts.opnfv.org/"$project"/"$img"
-        gsutil setmeta -h "Content-Type:image/jpeg" \
-                        -h "Cache-Control:private, max-age=0, no-transform" \
-                        gs://artifacts.opnfv.org/"$project"/"$img"
-        cat gsoutput.txt
-        rm -f gsoutput.txt
-
-done
-
+echo
+echo "Build"
+echo "-----"
+echo
+
+make
+
+echo
+echo "Upload"
+echo "------"
+echo
+
+# NOTE: make sure source parameters for GS paths are not empty.
+[[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
+[[ $GERRIT_PROJECT =~ .+ ]]
+[[ $GERRIT_BRANCH =~ .+ ]]
+
+gs_path_review="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
+if [[ $GERRIT_BRANCH = "master" ]] ; then
+    gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT"
+else
+    gs_path_branch="artifacts.opnfv.org/$GERRIT_PROJECT/${{GERRIT_BRANCH##*/}}"
+fi
+
+if [[ $JOB_NAME =~ "verify" ]] ; then
+    gsutil cp -r build/* "gs://$gs_path_review/"
+    echo
+    echo "Document is available at http://$gs_path_review"
+else
+    gsutil cp -r build/design_docs "gs://$gs_path_branch/"
+    gsutil cp -r build/requirements/html "gs://$gs_path_branch/"
+    gsutil cp -r build/requirements/latex/*.pdf "gs://$gs_path_branch/"
+    echo
+    echo "Latest document is available at http://$gs_path_branch"
+
+    if gsutil ls "gs://$gs_path_review" > /dev/null 2>&1 ; then
+        echo
+        echo "Deleting Out-of-dated Documents..."
+        gsutil rm -r "gs://$gs_path_review"
+    fi
+fi
diff --git a/jjb/genesis/docu-verify.sh b/jjb/genesis/docu-verify.sh
deleted file mode 100644 (file)
index 1f0c395..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-set -e
-set -o pipefail
-
-project="$(git remote -v | head -n1 | awk '{{print $2}}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')"
-export PATH=$PATH:/usr/local/bin/
-
-git_sha1="$(git rev-parse HEAD)"
-docu_build_date="$(date)"
-
-files=()
-while read -r -d ''; do
-       files+=("$REPLY")
-done < <(find . -type f -iname '*.rst' -print0)
-
-for file in "${{files[@]}}"; do
-
-       file_cut="${{file%.*}}"
-       gs_cp_folder="$(echo "$file"| cut -d "/" -f2,3)"
-
-       # sed part
-       sed -i "s/_sha1_/$git_sha1/g" $file
-       sed -i "s/_date_/$docu_build_date/g" $file
-
-       # rst2html part
-       echo "rst2html $file"
-       rst2html $file > $file_cut".html"
-
-       echo "rst2pdf $file"
-       rst2pdf $file -o $file_cut".pdf"
-
-done
-
index 671b387..6fead13 100644 (file)
 
     builders:
         - shell:
-            !include-raw docu-verify.sh
+            !include-raw docu-build.sh