I have a step that builds a docker image. Normally, I'd have this done when a merge happens, but in this case, I want to prove it works, so I'm trying to force it to run when as part of the normal build. Yet, regardless Gitlab (the cloud version) cannot or will not find a "runner" to get this done. This is my .gitlab-ci.yml file. The stage/step in question is
build-docker-image
This job stays in pending with the following message:
This job is stuck because of one of the following problems. There are no active runners online, no runners for the protected branch , or no runners that match all of the job's tags: build-docker-image
Go to project CI settings
stages:
- build-app
- test
- build-docker-image
- deploy-develop
- deploy-staging
- deploy-prod
variables:
APP: myapp
##########################################
# Build
##########################################
build-app:
stage: build-app
image:
name: mirror.gcr.io/library/maven:3.8.4-openjdk-17
variables:
GIT_DEPTH: 5
cache:
key: Maven
paths:
- .mvn/
artifacts:
paths:
- target/myapp-*.jar
expire_in: 1 month
tags:
- build
script:
- mvn -DskipTests -Dmaven.repo.local=$(pwd)/.mvn package
##########################################
# Test
##########################################
test:
stage: test
image:
name: mirror.gcr.io/library/maven:3.8.4-openjdk-17
variables:
GIT_DEPTH: 51
cache:
key: Maven
paths:
- .mvn/
artifacts:
paths:
- target/myapp-*.jar
expire_in: 1 month
tags:
- build
script:
- mvn test -Dmaven.repo.local=$(pwd)/.mvn test
##########################################
# Build Docker Image
##########################################
build-docker-image:
stage: build-docker-image
variables:
GIT_DEPTH: 5
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
dependencies:
- build-app
tags:
- build-docker-image
script:
- mkdir -p /kaniko/.docker
- echo $GCP_DOCKER | base64 -d > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "us.gcr.io/mycompany-ops/${CI_PROJECT_NAME}:${CI_COMMIT_SHORT_SHA}"
--build-arg GIT_SHA=${CI_COMMIT_SHORT_SHA}
--build-arg GIT_TAG=${CI_COMMIT_TAG}
--build-arg BUILT_ON="$(date)"
when:
# only:
# - main
Tags within .gitlab-ci.yml
map jobs to runners. If you have no runners tagged with build-docker-image
, then you will get the following error message:
This job is stuck because of one of the following problems. There are no
active runners online, no runners for the protected branch, or no runners
that match all of the job's tags: build-docker-image
If you want to use the same runner as other steps in your pipeline, change the following:
##########################################
# Build Docker Image
##########################################
build-docker-image:
stage: build-docker-image
# ...
tags:
- build
script:
# ...