Make Zuul's environment available to shell jobs

The idea is to use `jq` locallty to extract whatever is relevant for
these jobs.

Change-Id: I4a549241016b20dab4338fea363cba266bdd38a8
diff --git a/playbooks/zuul-var-to-json/run.yaml b/playbooks/zuul-var-to-json/run.yaml
new file mode 100644
index 0000000..6c97ecf
--- /dev/null
+++ b/playbooks/zuul-var-to-json/run.yaml
@@ -0,0 +1,6 @@
+- hosts: all
+  tasks:
+    - name: Export Zuul variables into JSON
+      copy:
+        dest: '{{ ansible_user_dir }}/zuul-env.json'
+        content: '{{ zuul | to_json }}'
diff --git a/zuul.yaml b/zuul.yaml
index 1bd9f31..fd1fdc2 100644
--- a/zuul.yaml
+++ b/zuul.yaml
@@ -2,6 +2,7 @@
     name: run-ci-build-sh
     description: |
       Run project's ./ci/build.sh script.
+    pre-run: playbooks/zuul-var-to-json/run.yaml
     run: playbooks/run-test-command/run.yaml
     vars:
       test_command: "ci/build.sh"