Right now I am trying to learn CI/CD on GitLab. Unfortunately, I cant make a simple pipeline run on my project. The runner doesn't seem to work somehow.
Here is an image of the project:
I wrote this in my .gitlab-ci.yml file:
build-job:
stage: build
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
test-job1:
stage: test
script:
- echo "This job tests something"
test-job2:
stage: test
script:
- echo "This job tests something, but takes more time than test-job1."
- echo "After the echo commands complete, it runs the sleep command for 20 seconds"
- echo "which simulates a test that runs 20 seconds longer than test-job1"
- sleep 20
deploy-prod:
stage: deploy
script:
- echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
environment: production
which is just the original code from the GitLab Tutorial for creating a simple pipeline.
Unfortunately i get this error afterwards:
Using docker image sha256:7053f62a27a84985c6ac886fcb5f9fa74090edb46536486f69364e3360f7c9ad for gcr.io/kaniko-project/executor:debug with digest gcr.io/kaniko-project/executor@sha256:fcccd2ab9f3892e33fc7f2e950c8e4fc665e7a4c66f6a9d70b300d7a2103592f ...
Error: unknown command "sh" for "executor"
Run 'executor --help' for usage
I'm using the shared runners of GitLab for the pipelines. Any help would be very appreciated!
The job is trying to use the image gcr.io/kaniko-project/executor
-- but this image defines an ENTRYPOINT
that points to the /kaniko/executor
binary and is therefore not compatible to be used as a job image in GitLab CI. See this answer for a full explanation of why this is problematic. Basically gitlab is trying to send commands to the job container, but is unexpectedly calling the executor
binary, which results in the error message which comes from /kaniko/executor
Error: unknown command "sh" for "executor"
Run 'executor --help' for usage
Because there's nothing in your .gitlab-ci.yml
configuration that would cause this image to be used, this is likely caused by the configuration of the runner you are using which specifies this as the default image when no image:
key is present.
You can specify a different image to get around this problem:
image: alpine # as a global key default
build-job:
stage: build
image: alpine # or on a per-job basis
If you really want to use this particular image (you almost certainly do not), you'll need to override the entrypoint:
build-job:
stage: build
image:
name: gcr.io/kaniko-project/executor
entrypoint: [""]
If you manage the GitLab runner configuration, you should change the default image
configuration to be a usable image.