You may not be able to do this purely in gitlab.yml , unfortunately, you can create a shell script as follows and check this with your control source
#!/bin/sh args=(" $@ ") CI_REGISTRY_IMAGE=${args[0]} PACKAGE_VERSION=$(cat package.json \ | grep version \ | head -1 \ | awk -F: '{ print $2 }' \ | sed 's/[",]//g' \ | tr -d '[[:space:]]') CONTAINER_RELEASE_IMAGE=$CI_REGISTRY_IMAGE\:$PACKAGE_VERSION cd /opt/core/bundle && docker build -t $CONTAINER_RELEASE_IMAGE . docker push $CONTAINER_RELEASE_IMAGE
Then execute this script with $CI_REGISTRY_IMAGE argument in gitlab.yml
# ... build: stage: build script:
As far as I know, this should work for you.
Thanks to DarrenN and dbaba on Github for its version of the package.json shell.
source share