test:image:docs-single is not run correctly
So, test:image:docs-single
is not run correctly. This test should check the Docker build of the stable branch that we define in the GITLAB_VERSION
variable.
test:image:docs-single:
extends:
- .docker_prepare
stage: test
variables:
DOCKERFILE: dockerfiles/single.Dockerfile
GITLAB_VERSION: '15.3'
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- $DOCKERFILE
script:
- docker build --file $DOCKERFILE --build-arg VER=${GITLAB_VERSION} .
The problem is that we don't checkout the respective gitlab-docs
branch, but rather we build the image based on the branch of the MR, which is most of the times branched off main
.
We can see in the Dockerfile that we run COPY . /source/
which copies the current branch checkout files into /source
.
Proposal
Before we build the image, we should add:
script:
- apk add --no-cache -U git
- git fetch -all
- git checkout -b $GITLAB_VERSION origin/$GITLAB_VERSION
- docker build ...
Edited by Achilleas Pipinellis