Canary build: save CWS upload/publish log
Also, fix a bug in the upload/publish command and fail when it exits
with a non-zero return code and doesn't fail with a ITEM_NOT_UPDATABLE
error.
Bug: twpowertools:20
Change-Id: I309e72b4a938be55782d0a7a18c1905ceb6cf304
diff --git a/.zuul.yaml b/.zuul.yaml
index 06f462c..a34642c 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -32,6 +32,7 @@
attempts: 1
pre-run: playbooks/nightly-build/pre.yaml
run: playbooks/nightly-build/run.yaml
+ post-run: playbooks/nightly-build/post.yaml
roles:
- zuul: zuul/jobs
secrets:
diff --git a/playbooks/nightly-build/post.yaml b/playbooks/nightly-build/post.yaml
new file mode 100644
index 0000000..5cb8988
--- /dev/null
+++ b/playbooks/nightly-build/post.yaml
@@ -0,0 +1,4 @@
+- name: Get CWS upload/publish log
+ hosts: all
+ roles:
+ - fetch-cws-log
diff --git a/roles/cws-publish/tasks/main.yaml b/roles/cws-publish/tasks/main.yaml
index 5ab7d8d..f8d4435 100644
--- a/roles/cws-publish/tasks/main.yaml
+++ b/roles/cws-publish/tasks/main.yaml
@@ -31,7 +31,11 @@
when: not (dry_run|bool)
ansible.builtin.command:
cmd: >
- "chrome-webstore-upload upload --auto-publish --extension-id {{ extension_id }}
+ chrome-webstore-upload upload --auto-publish --extension-id {{ extension_id }}
--source {{ zuul.project.src_dir|quote }}/out/{{ zip_file.stdout|quote }}
- --client-id {{ credentials.clientId|quote }} --refresh-token {{ credentials.refreshToken|quote }}"
+ --client-id {{ credentials.clientId|quote }} --refresh-token {{ credentials.refreshToken|quote }}
+ 2>cws-log.txt
no_log: True
+ register: uploadcmd
+ failed_when:
+ - not (uploadcmd.rc == 0 or ('ITEM_NOT_UPDATABLE' in uploadcmd.stderr))
diff --git a/roles/fetch-cws-log/tasks/main.yaml b/roles/fetch-cws-log/tasks/main.yaml
new file mode 100644
index 0000000..faeb65b
--- /dev/null
+++ b/roles/fetch-cws-log/tasks/main.yaml
@@ -0,0 +1,14 @@
+- name: Is there a cws-log.txt
+ register: stat_log
+ stat:
+ path: "{{ zuul.project.src_dir }}/cws-log.txt"
+
+- name: Store on executor
+ when: stat_log.stat.exists
+ synchronize:
+ mode: pull
+ src: "{{ zuul.project.src_dir }}/cws-log.txt"
+ dest: "{{ zuul.executor.log_root }}/cws-log.txt"
+ verify_host: true
+ owner: no
+ group: no