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):
- project: minigrid/cicd
# Added this after error described below - these are defined in the included config
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
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
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:
- 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.
If I remove <<: *automatically_builds or make it always resolve to true then it works fine. But with it I get the No stages / jobs for this pipeline. error.
Note that pasting this directly into CI Lint works fine, its only when included that it fails.
I’m not sure if this should be considered a bug with CI Lint or if I’m expecting too much. Maybe the file is really supposed to be considered invalid in these cases ¯_(ツ)_/¯
Yeah sorry that is what it is in the real file, and if I change to that in the minimal example it fails also.
I just changed it to the contrived example to test.
It passes if I update to - if: ' "merge_request_event" == "merge_request_event"'
Just a quick follow-up to this. If I ask the lint to Simulate a pipeline created for the default branch the config does fail, because there is nothing in that fragment that will cause the build-push job to run on the default branch. It will pass if you change it to this: