I am having an issue in building multiple docker images with a time delay of 15 min each so that the during the build stage each image connects to a server and do some processing and it should happen one after another.
`build-docker-images:
extends: .docker-build-job
stage: build parallel:
matrix:'
'- DOCKER_BUILD_CONTEXT: "."
DOCKER_BUILD_NAME: "$DOCKER_IMAGE1"
DOCKER_BUILD_DOCKERFILE: "/Dockerfile1"
- DOCKER_BUILD_CONTEXT: "."
DOCKER_BUILD_NAME: "$DOCKER_IMAGE2"
DOCKER_BUILD_DOCKERFILE: "/Dockerfile2"
- DOCKER_BUILD_CONTEXT: "."`
and so on.
I tried to add sleep of 15 min in between each build like this
`- DOCKER_BUILD_CONTEXT: "."
DOCKER_BUILD_NAME: "$DOCKER_IMAGE2"
DOCKER_BUILD_DOCKERFILE: "/Dockerfile2"
- sleep: 900`
I also have some of the images which doesn't require sleep and all are part of single parallel job. I tried to browse through the documentation and portal i am not able to achieve it..
I think what you're trying to achieve is not possible, as of today matrix
key does not offer a way to add delay to the jobs. Also from a developer point of view, it makes sense that matrix
jobs run without delays, as this is what you'd expect, everything running in parallel to have faster executions.
Coming back to your scenario, it is probably best to reorganise your CI and split the building into different jobs, given that you have some images that can run in parallel but others don't. You can create a Directed Acylic Graph(DAG) like architecture that would match your scenario.
Here's very rough schema of what you could build:
This allows you to run build1
and build-n
in parallel, while your dependant jobs wait one for another without wasting much execution time.