1

I'm trying to follow this tutorial to enable formatting checks using black in GitLab CI.

To make things simpler, I've transferred the code from .lint-ci.yml over to .gitlab-ci.yml. The tag of the shared runner that I'm using is gitlab-ci. I'm getting the following error when the pipeline gets run:

bash: line 80: apk: command not found
ERROR: Job failed: exit status 1

Obviously, that's getting thrown for the apk --no-cache add py3-pip python3-dev gcc linux-headers musl-dev libffi-dev openssl-dev git line.

Here's the .gitlab-ci.yml file:

formatter:
  stage: build
  tags:
    - gitlab-ci
  image: alpine
  only:
    - branches
  before_script:
    - apk --no-cache add py3-pip python3-dev gcc linux-headers musl-dev libffi-dev openssl-dev git
    - pip install black
  script:
    - black . --check
  allow_failure: false

Can someone help me solve this issue?

As requested by @slauth, here's the full output of the job:

Running with gitlab-runner 11.6.1 (id1)
  on gitlab-ci -CzBAN4M
Using Shell executor...
Running on gitserver...
Fetching changes...
HEAD is now at id2 a
From http://gitserver....
Checking out id3 as gitlabci...
Skipping Git submodules setup
$ apk --no-cache add py3-pip python3-dev gcc linux-headers musl-dev libffi-dev openssl-dev git
bash: line 80: apk: command not found
ERROR: Job failed: exit status 1
BubbleMaster
  • 184
  • 2
  • 10
  • Are you using gitlab.com or a self-hosted server? Maybe your runner is using an [executor](https://docs.gitlab.com/runner/executors/) that does not support the `image:` configuration, see [this compatibility chart](https://docs.gitlab.com/runner/executors/index.html#compatibility-chart). – slauth Jul 28 '21 at 13:35
  • @slauth I'm using a self-hosted server, but looking at multiple `.gitlab-ci.yml` files in other projects, I can see that the `image:` configuration pops up everywhere, so I don't think that's the issue. – BubbleMaster Jul 28 '21 at 14:01
  • Could you post the complete output of the `formatter` job? – slauth Jul 28 '21 at 14:15
  • @slauth I've edited the question to include the full output of the `formatter` job. – BubbleMaster Jul 28 '21 at 14:23
  • Notice the "Using Shell executor..." line. Maybe there are other runners available? – slauth Jul 28 '21 at 14:31
  • Thank you, changing the `gitlab-ci` tag to `docker` fixed the issue. :) I wanted to try that hours ago, but since there are multiple runners that use the tag `docker`, I wasn't sure what would happen if I used that tag. Please post an answer so that I can accept it. – BubbleMaster Jul 28 '21 at 14:37

1 Answers1

1

Your runner is using the "Shell" executor which does not support the image: configuration, see this compatibility chart.

slauth
  • 2,667
  • 1
  • 10
  • 18