Need to have reviews under /$PROJECT/$review_number
[releng.git] / jjb / releng-macros.yaml
index 68a62f4..b43a76d 100644 (file)
@@ -7,6 +7,14 @@
             name: PROJECT
             default: '{project}'
             description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
+        - string:
+            name: GS_BASE
+            default: artifacts.opnfv.org/$PROJECT
+            description: "URL to Google Storage."
+        - string:
+            name: GS_BASE_PROXY
+            default: build.opnfv.org/artifacts/$PROJECT
+            description: "URL to Google Storage proxy"
 
 - parameter:
     name: gerrit-parameter
@@ -33,7 +41,7 @@
     scm:
         - git:
             credentials-id: '{credentials-id}'
-            url: 'ssh://gerrit.opnfv.org:29418/$PROJECT'
+            url: '$GIT_BASE'
             refspec: '{refspec}'
             branches:
                 - 'origin/$GERRIT_BRANCH'
             timeout: 360
             fail: true
 
+- trigger:
+    name: 'brahmaputra-trigger-daily-disabled'
+    triggers:
+        - timed: ''
+
+- trigger:
+    name: 'brahmaputra-trigger-daily-enabled'
+    triggers:
+        - timed: '0 2 * * *'
+
 - trigger:
     name: gerrit-trigger-patch-submitted
     triggers:
     name: jacoco-nojava-workaround
     builders:
         - shell: 'mkdir -p $WORKSPACE/target/classes'
+
+
+# New Releng macros
+
+- builder:
+    name: build-html-and-pdf-docs-output
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o xtrace
+            export PATH=$PATH:/usr/local/bin/
+            git clone ssh://gerrit.opnfv.org:29418/releng
+            GERRIT_COMMENT=gerrit_comment.txt ./releng/utils/docs-build.sh
+
+- builder:
+    name: upload-under-review-docs-to-opnfv-artifacts
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o pipefail
+            set -o xtrace
+            export PATH=$PATH:/usr/local/bin/
+
+            [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
+            [[ -d docs_output ]] || exit 0
+
+            echo
+            echo "###########################"
+            echo "UPLOADING DOCS UNDER REVIEW"
+            echo "###########################"
+            echo
+
+            gs_base="artifacts.opnfv.org/$PROJECT/review"
+            gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
+            local_path="upload/$GERRIT_CHANGE_NUMBER"
+
+            mkdir -p upload
+            mv docs_output "$local_path"
+            gsutil -m cp -r "$local_path" "gs://$gs_base"
+
+            if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
+                gsutil -m setmeta \
+                    -h "Content-Type:text/html" \
+                    -h "Cache-Control:private, max-age=0, no-transform" \
+                    "gs://$gs_path"/**.html
+            fi
+
+            echo "Document link(s):" >> gerrit_comment.txt
+            find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
+                sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
+
+- builder:
+    name: upload-generated-docs-to-opnfv-artifacts
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o pipefail
+            set -o xtrace
+            export PATH=$PATH:/usr/local/bin/
+
+            [[ -d docs_output ]] || exit 0
+
+            echo
+            echo "########################"
+            echo "UPLOADING GENERATED DOCS"
+            echo "########################"
+            echo
+
+            gs_path="$GS_URL/docs"
+            local_path="upload/docs"
+
+            mkdir -p upload
+            mv docs_output "$local_path"
+            gsutil -m cp -r "$local_path" "gs://$GS_URL"
+
+            if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
+                gsutil -m setmeta \
+                    -h "Content-Type:text/html" \
+                    -h "Cache-Control:private, max-age=0, no-transform" \
+                    "gs://$gs_path"/**.html
+            fi
+
+            echo "Document link(s):" >> gerrit_comment.txt
+            find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
+                sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
+
+- builder:
+    name: report-docs-build-result-to-gerrit
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o pipefail
+            set -o xtrace
+            export PATH=$PATH:/usr/local/bin/
+            if [[ -e gerrit_comment.txt ]] ; then
+                echo
+                echo "posting review comment to gerrit..."
+                echo
+                cat gerrit_comment.txt
+                echo
+                ssh -p 29418 gerrit.opnfv.org \
+                    "gerrit review -p $GERRIT_PROJECT \
+                     -m '$(cat gerrit_comment.txt)' \
+                     $GERRIT_PATCHSET_REVISION"
+            fi
+
+- builder:
+    name: remove-old-docs-from-opnfv-artifacts
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o pipefail
+            set -o xtrace
+            export PATH=$PATH:/usr/local/bin/
+
+            [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
+
+            gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
+
+            if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
+                echo
+                echo "Deleting Out-of-dated Documents..."
+                gsutil -m rm -r "gs://$gs_path"
+            fi
+            gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
+
+            if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
+                echo
+                echo "Deleting Out-of-dated Documents..."
+                gsutil -m rm -r "gs://$gs_path"
+            fi
+
+- builder:
+    name: upload-review-docs
+    builders:
+        - build-html-and-pdf-docs-output
+        - upload-under-review-docs-to-opnfv-artifacts
+        - report-docs-build-result-to-gerrit
+
+- builder:
+    name: upload-merged-docs
+    builders:
+        - build-html-and-pdf-docs-output
+        - upload-generated-docs-to-opnfv-artifacts
+        - report-docs-build-result-to-gerrit
+        - remove-old-docs-from-opnfv-artifacts