lab icon indicating copy to clipboard operation
lab copied to clipboard

lab ci lint and includes

Open svenXY opened this issue 6 years ago • 6 comments

Hi, seems to me that included yml (using "local" style) files are not found:

$ lab ci lint 2019/10/02 16:03:06 ci_lint.go:30: ci yaml invalid: Local file ci/lab_basic.yml does not have project!

.gitlab-ci.yml:

include:
  - 'ci/lab_basic.yml'

stages:
  - test

ci/lab_basic.yml

.base:
  variables:
    MYVAR: "some stupid string"

test includes:
  extends: .base
  stage: test
  script:
    - echo ${MYVAR}
  image: registry.gitlab.com/project/gitlab-cli:latest

svenXY avatar Oct 02 '19 14:10 svenXY

+1 I observed this behavior too.

Neonox31 avatar Oct 07 '19 12:10 Neonox31

I'm not sure if this is something we can support, the API at least only accepts the .gitlab-ci.yml contents and validates from there (essentially the same as the web version)

https://docs.gitlab.com/ee/api/lint.html

If anybody knows better I'd be interested to know. It'd be fairly involved, but in theory if lab were to follow the includes and prepend the file contents it should work about the same

zaquestion avatar Oct 11 '19 03:10 zaquestion

I reproduced with another error message:

$ lab ci lint
2021/02/12 10:55:11 ci_lint.go:32: ci yaml invalid: POST https://my.private.gitlab.yoyo/api/v4/ci/lint: 401 {message: 401 Unauthorized}

(lab version: 0.19.0)

MartinDelille avatar Feb 12 '21 10:02 MartinDelille

@MartinDelille I do not think this is the same issue. We have two inhouse gitlab-instances, one running 13.8.4, where I get above message even for projects without any includes and the other 13.7.6 where this still works fine. My guess would be, that this is https://gitlab.com/gitlab-org/gitlab/-/issues/321290

mfriedenhagen avatar Feb 15 '21 10:02 mfriedenhagen

Indeed. This is fixed: I know have the include issue described in the first place.

MartinDelille avatar Mar 02 '21 08:03 MartinDelille

While inspecting the auth issue I detected that there are two API resources for linting. One which is project specific and one stand alone one. I guess lab must use the project specific one (https://docs.gitlab.com/ee/api/lint.html#validate-a-ci-yaml-configuration-with-a-namespace), so GitLab is able to deduce the local include. (Including stuff via URL or the project/ref/file syntax works fine with stand alone resource)

mfriedenhagen avatar Mar 02 '21 18:03 mfriedenhagen