Tim Andersson has proposed merging qa-jenkins-jobs:fix-rtd-build-trigger into 
qa-jenkins-jobs:master.

Requested reviews:
  Canonical Platform QA Team (canonical-platform-qa)

For more details, see:
https://code.launchpad.net/~canonical-platform-qa/qa-jenkins-jobs/+git/qa-jenkins-jobs/+merge/482612

If the latest commit is null from the readthedocs API, we just trigger a 
rebuild.
-- 
Your team Canonical Platform QA Team is requested to review the proposed merge 
of qa-jenkins-jobs:fix-rtd-build-trigger into qa-jenkins-jobs:master.
diff --git a/jobs/autopkgtest-cloud/jobs.yaml b/jobs/autopkgtest-cloud/jobs.yaml
index 707e8ed..0a22328 100644
--- a/jobs/autopkgtest-cloud/jobs.yaml
+++ b/jobs/autopkgtest-cloud/jobs.yaml
@@ -40,15 +40,22 @@
         - clear-artifacts:
         - shell: |
             #!/bin/bash
-            set -eu
+            set -ex
+            submit_build(){
+                curl -sS -X POST -H "Authorization: Token ${RTD_TOKEN}" https://readthedocs.org/api/v3/projects/autopkgtest-cloud/versions/latest/builds/
+            }
 
             RTD_LATEST_COMMIT=$(curl -H "Authorization: Token ${RTD_TOKEN}" https://readthedocs.org/api/v3/projects/autopkgtest-cloud/builds/ | jq -r '.results[0]' | jq -r '.commit')
+            if [[ $RTD_LATEST_COMMIT == 'null' ]]; then
+                printf "Couldn't read latest commit from readthedocs, submitting build request by default\n"
+                submit_build
+                exit $?
+            fi
             git clone https://git.launchpad.net/autopkgtest-cloud
             cd autopkgtest-cloud || exit 1
             if ! git diff --quiet "${RTD_LATEST_COMMIT}" docs/ .readthedocs.yaml; then
                 printf "Changes have been made to docs since last built version, building on readthedocs...\n"
-                curl -sS -X POST -H "Authorization: Token ${RTD_TOKEN}" https://readthedocs.org/api/v3/projects/autopkgtest-cloud/versions/latest/builds/
-                printf "readthedocs build request submitted\n"
+                submit_build
             else
                 printf "No changes to docs/ since latest build, not building\n"
             fi
-- 
Mailing list: https://launchpad.net/~canonical-ubuntu-qa
Post to     : canonical-ubuntu-qa@lists.launchpad.net
Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa
More help   : https://help.launchpad.net/ListHelp

Reply via email to