I have a .gitlab-ci.yml
with lots of variables which are defined sequentially from some earlier variables.
Instead of beginning with a hardcoded timestamp I want to use the predefined CI_JOB_STARTED_AT but I only want the YYYYMMDD part of it and not the whole ISO8601 she-bang.
I tried this
<code>variables:
# full ISO8601 timestamp, keep yyyy-mm-dd
TEMP_REV1: "${CI_JOB_STARTED_AT:0:10}"
# remove all "-"
TEMP_REV2: "${TEMP_REV1//-/}"
TARGET_IMAGE_REV:
value: "${TEMP_REV2}01"
description: "yyyymmdd## timestamp+version# for image"
TARGET_RELEASE_TAG: "${TARGET_IMAGE_VERSION}-${TARGET_IMAGE_REV}"
# ... etc.
</code>
<code>variables:
# full ISO8601 timestamp, keep yyyy-mm-dd
TEMP_REV1: "${CI_JOB_STARTED_AT:0:10}"
# remove all "-"
TEMP_REV2: "${TEMP_REV1//-/}"
TARGET_IMAGE_REV:
value: "${TEMP_REV2}01"
description: "yyyymmdd## timestamp+version# for image"
TARGET_RELEASE_TAG: "${TARGET_IMAGE_VERSION}-${TARGET_IMAGE_REV}"
# ... etc.
</code>
variables:
# full ISO8601 timestamp, keep yyyy-mm-dd
TEMP_REV1: "${CI_JOB_STARTED_AT:0:10}"
# remove all "-"
TEMP_REV2: "${TEMP_REV1//-/}"
TARGET_IMAGE_REV:
value: "${TEMP_REV2}01"
description: "yyyymmdd## timestamp+version# for image"
TARGET_RELEASE_TAG: "${TARGET_IMAGE_VERSION}-${TARGET_IMAGE_REV}"
# ... etc.
But it doesn’t work at all, the variable appears empty. I’d have to define ~10 other variables if I moved all of it into the script section.
Is this possible at all?
Thanks!