How to run a custom docker image in the gitlab-ci

Hi there
I have three applications. (let’s call them A, B, and C)

The C application just has some gitlab-ci.yml files which I use them in A and B.

I use the include keyword for using the gitlab-ci.yml in the A and B. something like this:

include:
– project: ‘C’
ref: main

I built a docker image for each application.
And now, In application B, when the pipeline is run on the test stage, an error appears saying that It wants the docker image of application A.

I changed the test stage inside the gitlab-ci of the application B like this:

mvn_test:
image: $IMAGE_ADDRESS:$IMAGE_VERSION
services:
- name: mysql:main
alias: mysql

And the image was successfully pulled.

And now the problem is: in the test stage, it uses just the docker image of application A.
whereas I want it use the docker image of C.

Actually, I want in the test stage of B, the docker image of A just run and then test stage use the docker image of C. but it’s not happened.

I hope I have conveyed what I mean.

I’ll be grateful if anybody guides me.

I edited the test stage from:

mvn_test:
image: $IMAGE_ADDRESS:$IMAGE_VERSION
services:
– name: mysql:main
alias: MySQL

to:

mvn_test:
services:
– name: mysql:main
alias: MySQL
– name: $IMAGE_ADDRESS:$IMAGE_VERSION
alias: $IMAGE_NAME

Now, everything is fine.
But the pipeline fails in the first run and I have to click on the Retry button to run the pipeline properly.

What can I do?