Override Zuul's LOG_PATH to use ZUUL_REF as unique identifier

Override Zuul's LOG_PATH to use ZUUL_REF as unique identifier
instead of ZUUL_UUID. ZUUL_REF is unique across a job build set
while ZUUL_UUID is unique per job. Uploading based on ZUUL_REF
allows child jobs to find parent jobs artifacts easily.

Note: This requires us to carry a patch [1] that has not yet
      landed upstream.

[1]: https://review.openstack.org/#/c/341154

Change-Id: I52d2e8c3b7c5da5341cdd768efecfdeb5db82ce5
diff --git a/zuul/zuul_functions.py b/zuul/zuul_functions.py
index 017b29a..5da124e 100644
--- a/zuul/zuul_functions.py
+++ b/zuul/zuul_functions.py
@@ -13,3 +13,15 @@
         return
     print "zuul_functions: set_node_options(", item, job, "): "
     params['OFFLINE_NODE_WHEN_COMPLETE'] = '1'
+
+    # Override Zuul's LOG_PATH to use ZUUL_REF as unique identifier
+    # instead of ZUUL_UUID. ZUUL_REF is unique across a job build set
+    # while ZUUL_UUID is unique per job. Uploading based on ZUUL_REF
+    # allows child jobs to find parent jobs artifacts easily.
+    ref_uuid = params['ZUUL_REF'].split('/')[-1]
+    params['LOG_PATH'] = "{base}/{pipeline}/{job}/{ref}".format(
+        base=params['BASE_LOG_PATH'],
+        pipeline=params['ZUUL_PIPELINE'],
+        job=job.name,
+        ref=ref_uuid
+    )