ci-dockerfiles-*: Refactor build name/version preparation

Share/reuse the code to keep behavior consistent.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Iae6b9e7a053eb52c439e67566d09368ea0e610b3
diff --git a/ci-dockerfiles-deployment/build-version.sh b/ci-dockerfiles-deployment/build-version.sh
new file mode 100644
index 0000000..71657a3
--- /dev/null
+++ b/ci-dockerfiles-deployment/build-version.sh
@@ -0,0 +1,6 @@
+#!/bin/bash -e
+if [ -n "${GERRIT_PATCHSET_REVISION}" ]; then
+    echo "#${BUILD_NUMBER}-${GERRIT_PATCHSET_REVISION:0:8}" > ${WORKSPACE}/version.txt
+else
+    echo "#${BUILD_NUMBER}" > ${WORKSPACE}/version.txt
+fi