Closed Jamesking56 closed 4 years ago
@Jamesking56 how does GitLab invoke it? Are you able to see the full run command?
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.
I am adding the option to have it run without any arguments by default (https://github.com/cytopia/docker-ansible-lint/issues/17)
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?
I have the same issue, running in gitlab too.
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
Thanks @ndegory Is this also working for @Jamesking56 , @DutchessNicole and @xmariopereira ?
Might also be related: https://github.com/cytopia/docker-yamllint/issues/14
Can confirm setting the entrypoint works :+1:
I will add this to the README
Thanks everyone for figuring this out :)
FWIW - gitlab ci only requires an empty entrypoint.
You can just use:
entrypoint: ['']
And it'll work fine.
Trying to use this on GitLab CI:
.gitlab-ci.yml
Output from GitLab CI: