LeMike
LeMike

Reputation: 3295

Gitlab-runner with syntax error

I recently used the docker image gitlab/gitlab-runner:9.1.0 in conjunction with a gitlab container to have some CI. An error occurs and similar support requests recommended using a different version, so I tried with :latest and some :1.11 too. Unfortunately it keeps telling me this error:

Running with gitlab-ci-multi-runner 1.11.4 (5e7ba4a)
  on foo (02cdacdc)
Using Docker executor with image pretzlaw/php:7.1-apache ...
Starting service mariadb:latest ...
Pulling docker image mariadb:latest ...
Waiting for services to be up and running...
Pulling docker image pretzlaw/php:7.1-apache ...
Running on runner-02cdacdc-project-7-concurrent-0 via 9d1d33dc9212...
Fetching changes...
HEAD is now at 7580815 QA: CI Lint
From http://idgaf.example.org/foo/bar
   7580815..affeede  develop    -> origin/develop
Checking out affeede as develop...
Skipping Git submodules setup
[: 1: [: Syntax error: end of file unexpected
[: 1: [: Syntax error: end of file unexpected
ERROR: Job failed: exit code 2

Neither do I know how to debug this nor do I see any problem in my container or test script. This is the .gitlab-ci.yml:

before_script:
  - composer install

test_7_1:
  image: pretzlaw/php:7.1-apache
  script: ls

It could be a problem of the container somewhere but I don't get it. Doing this manually (with the recent failed docker container) everything works fine:

docker container exec 68c7b5448a56 ls
bin
builds
...

How do I trace back the problem? What is it all about?

It's for GitLab 9.1.1-ce.0.

Upvotes: 13

Views: 3606

Answers (2)

Mastergalen
Mastergalen

Reputation: 4389

As a workaround to the bug mentioned by Balthazar, try overriding the entrypoint in .gitlab-ci.yml as illustrated in the GitLab docs:

For Docker 17.06 and later:

image:
  name: super/sql:experimental
  entrypoint: [""]

For Docker 17.03 and earlier:

image:
  name: super/sql:experimental
  entrypoint: ["/bin/sh", "-c"]

Upvotes: 0

Preview
Preview

Reputation: 35796

As pointed out by #1550, the problem seems to be coming from the shell detection done in the bash.go file between lines 16-31 which it is injected without newlines and thus creating the syntax error you are yourself experiencing.

Since you have a custom entrypoint in your Dockerfile and it looks like you have not passed quotes to the arguments of the exec here, that's what I think is failing and should be modified.

Change it to

exec "${*}"

Upvotes: 3

Related Questions