Difficulty running stages from included configs

We currently store our CI configs in a separate project and use the settings in the UI to link them.
For various reasons we want to move to using a .gitlab-ci.yml in the repo itself that includes these files from the cicd repo.

My current attempt is (note that the existing company-backend/.gitlab-ci.yml works perfectly):

include:
  - project: minigrid/cicd
    ref: 'chore/run-quality-separately'
    file:
      - 'company-backend/.gitlab-ci.yml'

# Added this after error described below - these are defined in the included config
stages:
  - TestAndBuild
  - AdditionalLinting
  - Deploy
  - Validate
  - ApproveQA
  - Live
  - PostJobs

Putting this into CI Lint is giving the following error:

I added the stages explicitly (as above) - which I wasn’t expecting to need to do since they are defined in the linked file - but still no luck.
My understanding from the docs is that the entire linked file is essentially merged with the .gitlab-ci.yml to create the yaml that runs. What am I missing?

I’ve omitted the included company-backend/.gitlab-ci.yml file since a) it works already and has been unchanged b) is 350+ lines

Hi @phil122

Have you run this pipeline or just put it through the lint?

No I haven’t yet - I can’t figure out how to run this pipeline in such a way that it overrides the project settings (which I cannot change as it will disrupt my team). If you know of a way then I can definitely give it a whirl!

I was running it in the CI lint tool with “Simulate” checked - which I think should perform the inclusion

Interesting!

Looking at the docs for include I wonder whether you need a leading slash on /company-backend/.gitlab-ci.yml?

Also, is chore/run-quality-separately a tag or branch?

The leading slash doesn’t seem to make any difference.

chore/run-quality-separately is a branch. If I change it to something deliberately wrong then CI Lint recognises the missing ref.

Interestingly, pasting the included file into CI Lint also fails. So I suspect there are further configuration settings that are currently being provided by the project settings that I am failing to provide…

Interesting! So it sounds like this isn’t anything obvious, at least AFAICT.

I wonder what happens if you make a simple branch on that repo, like testci and remove everything in the .gitlab-ci.yml except a really simple job, like:

stages:
    - test

test:
    script:
        - echo "Hello, world!"

Hopefully that will work fine, then I’d change the branch name from testci to chore/testci and see if that makes a difference.

If all of that works fine, then I’d guess it’s something in your .gitlab-ci.yml that you are including. It’s hard to know what that would be, but you could try linting that file in its original minigrid/cicd project, and cutting out the stages and jobs that you aren’t using in the downstream project, and see if that lints OK.

1 Like

Thanks - the test job works perfectly - good idea.

I’ll coordinate with the devops team to find what the problem inside the cicd/.gitlab-ci.yml might be