Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 752
LeMike Avatar asked Apr 30 '17 21:04

LeMike


People also ask

Why is my GitLab runner not picking up jobs?

You can also check if your runner is allowed to run untagged jobs - you can do that under Admin and then edit it to see if that option is enabled. The runner is a specific runner for the project and not a shared one.

Why is my GitLab pipeline failing?

It might be a security vulnerability The code in your most recent commit could be vulnerable, or a dependency could be at risk, either of which would trigger a failed security test and thus a failed pipeline.

Where is GitLab runner config file?

You can find the config. toml file in: /etc/gitlab-runner/ on *nix systems when GitLab Runner is executed as root (this is also the path for service configuration)


1 Answers

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 "${*}"
like image 79
Preview Avatar answered Sep 30 '22 04:09

Preview