I have autoscaled the gitlab-runner on AWS spot instances. And it works fine.
And I have an issue when running the jobs. Below is my .gitlab-ci.yml and it has two stages.
stages:
- build
- dev1:build
build:
stage: build
script:
- docker build --rm -t broker-connect-dev1-${CI_COMMIT_SHORT_SHA} -f BrokerConnect/Dockerfile .
only:
- dev1/release
tags:
- itela-spot-runner
build-dev1:
stage: dev1:build
script:
- docker tag broker-connect-dev1-${CI_COMMIT_SHORT_SHA}:latest 19950818/broker-connect:${DEV1_TAG}
only:
- dev1/release
tags:
- itela-spot-runner
And here comes the problem, since I am using spot instances to run the jobs sometimes the build stage happens in one spot instance and the dev1:build stage happens in another spot instance. When this happens dev1:build fails as it cannot find the image broker-connect-dev1-${CI_COMMIT_SHORT_SHA} because it has been built in a separate spot instance. In gitlab, or in gitlab-runner, is there a way to control this behavior and run these two jobs build and dev1:build in the same spot instance?