Reputation: 17332
I'm doing the productive deploy in gitlab manually. I'm using docker container.
Clicking on the 'Play'-Button in the pipeline list should do the deploy.
But how do I get the version of the selected container? Doing this script is always trying to pull the latest
version, which should not be. I want to pull the 'selected' container.
deploy_prod:
stage: deploy
script:
- docker pull $CI_REGISTRY_IMAGE # here selected version is missing
# ...
when: manual
environment:
name: productive
url: https://example.com
only:
- master
Upvotes: 0
Views: 644
Reputation: 4665
As mentioned in the comments to your question, simply use the same script you used to push the image, to pull it in the deploy stage.
Here's an example pull.sh
script:
#!/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
docker pull $CONTAINER_RELEASE_IMAGE
Notice the pull
instead of the push
in the last line.
Then modify your deploy job like this:
deploy_prod:
stage: deploy
script:
- ./pull.sh $CI_REGISTRY_IMAGE
# ...
when: manual
environment:
name: productive
url: https://example.com
only:
- master
Upvotes: 1