Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with GitLab CI #14

Closed
Jamesking56 opened this issue Dec 8, 2019 · 11 comments
Closed

Does not work with GitLab CI #14

Jamesking56 opened this issue Dec 8, 2019 · 11 comments
Assignees

Comments

@Jamesking56
Copy link

Trying to use this on GitLab CI:

.gitlab-ci.yml

ansible-lint:
  image: cytopia/ansible-lint
  stage: lint
  script:
    - ansible-lint -R -x idempotency,ANSIBLE0010 *.yml --nocolor

Output from GitLab CI:

WARNING: Couldn't open sh - No such file or directory
@cytopia
Copy link
Owner

cytopia commented Dec 9, 2019

@Jamesking56 how does GitLab invoke it? Are you able to see the full run command?

@cytopia cytopia self-assigned this Dec 9, 2019
@DutchessNicole
Copy link

DutchessNicole commented Feb 6, 2020

Gitlab checks out the code repository inside a directory in /builds/<namespace>/<project name> and tries to cd into it.

From there it'll try to run the script block with any elements passed to it

so given this config:

stages:
  - lint
ansible-linter:
  variables:
    CI_DEBUG_TRACE: "true"
  image: cytopia/ansible-lint
  stage: lint
  tags: ['generic']
  script:
    - ansible-lint inventories/playbook.yml

gitlab starts a docker container, checks out the code as mentioned above, tries to cd to the code directory and that is where it fails.
It never gets to the script block where the ansible-lint command is.

@cytopia
Copy link
Owner

cytopia commented Mar 22, 2020

I am adding the option to have it run without any arguments by default (#17)

#18

@DutchessNicole
Copy link

stages:
  - lint

ansible-linter:
  image: cytopia/ansible-lint
  stage: lint
  tags: ['generic']
  script:
    - echo $PATH
    - pwd
    - which ansible-lint
    - ansible-lint inventories/bootstrap.yml
    - ansible-lint inventories/configure.yml

Given the preceding gitlab-ci file, we still get the missing sh lines:

WARNING: Couldn't open sh - No such file or directory
WARNING: Couldn't open sh - No such file or directory

I looked through the linked issues #17 and #18 but I don't quite see how they relate to this issue?
Could you elaborate on what the fix would be?

@xmariopereira
Copy link

I have the same issue, running in gitlab too.

@ndegory
Copy link

ndegory commented Jun 9, 2020

I made it work by specifying an entrypoint:

default:
  image:
    name: cytopia/ansible-lint:latest
    entrypoint: ["/bin/sh", "-c"]

stages:
  - lint

ansible-linter:
  stage: lint
  script:
    - ansible-lint *.yaml
  only:
    - merge_requests
    - master

@cytopia
Copy link
Owner

cytopia commented Jun 12, 2020

Thanks @ndegory Is this also working for @Jamesking56 , @DutchessNicole and @xmariopereira ?

Might also be related: cytopia/docker-yamllint#14

@Jamesking56
Copy link
Author

Can confirm setting the entrypoint works 👍

@cytopia
Copy link
Owner

cytopia commented Jun 13, 2020

I will add this to the README

cytopia added a commit that referenced this issue Jun 13, 2020
@cytopia
Copy link
Owner

cytopia commented Jun 13, 2020

Thanks everyone for figuring this out :)

@katanacrimson
Copy link

katanacrimson commented Dec 31, 2020

FWIW - gitlab ci only requires an empty entrypoint.

You can just use:

    entrypoint: ['']

And it'll work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants