Zuul: Fix artifact retrieval

With our updated Zuul (and the associated update of the base job), a
Zuul manifest is almost always returned as an artifact form all builds.
This has implications with out dependency caching -- the code previously
assumed that we could just pick *the* artifact from the most recent
change item from the CzechLight/Dependencies repo, and that would be our
tarball. That's no longer the case, it could as well be the Zuul
manifest, so let's bring in more JSON magic:

- `.artifacts[]?` is a generator which return the "artifacts" member of
the input as individual items in a sequence, or a null on error ("no
artifacts")
- `select(.foo == "bar")` filters by attribute value, that one is easy,
- `[.artifacts[]? | select ... ]` converts that generator back to an array,
- `[-1]?` selects the last item, if there's any, otherwise returning null,
- ...which is then turned into an empty string, or the resulting value
by `+ ""`.

Change-Id: Ieafa1be1f7066e5005a8e35f4fe86887cbaff3e5
diff --git a/ci/build.sh b/ci/build.sh
index d070319..956fa0d 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -64,12 +64,7 @@
 export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
 export PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
 
-ARTIFACT_URL=""
-
-if [[ "$(jq < ~/zuul-env.json -r '.artifacts[-1].project')" = "CzechLight/dependencies" &&
-      "$(jq < ~/zuul-env.json -r '.artifacts[-1].name')" = "tarball" ]]; then
-    ARTIFACT_URL=$(jq < ~/zuul-env.json -r '.artifacts[-1].url')
-fi
+ARTIFACT_URL=$(jq < ~/zuul-env.json -r '[.artifacts[]? | select(.name == "tarball") | select(.project == "CzechLight/dependencies")][-1]?.url + ""')
 
 DEP_SUBMODULE_COMMIT=$(git ls-tree -l master submodules/dependencies | cut -d ' ' -f 3)