CI lint API doesn't properly lint local includes due to missing branch context
Feature branches are a proven tool for clean development. The increasing functionality surrounding gitlab CI and its lint API make it easier to develop pipelines separated into multiple files. The existing API endpoints allow for linting of CI scripts that only include scripts on the default branch, but not newly added ones. By adding either a keyword or another variable to the project specific lint API, this can be solved.
Problem to solve
As a developer, I want to test new CI scripts with the linting API, so I can get faster feedback whilst using feature branches.
User experience goal
The user should be able to test new CI scripts including referencing new files on a non-default branch with the project specific lint endpoint.
Extend the existing API endpoint
/api/v4/projects/:id:/ci/lint with either a flag like
same_branch (telling it to consider the branch the call was triggered from), or another variable as in
/api/v4/projects/:id:/ci/lint/branch/:id: so that it can be specified (e.g. using one of the available environment variables in CI.
- Create a new project to organize multiple ci-scripts
- Define a script that sends local files to the specified API endpoint (e.g. like this) and add it to the
- Create a new branch for a new feature
- Add a new
.ymlfile, e.g. including the definition of a single job
- Add a new
.ymlfile, e.g. including the definition of a pipeline, referencing the local file from the previous step
Currently, this yields an error (
Local file referenced.yml
does not exist!), because only the default branch is considered (I assume).
All logic necessary for the above seems already to be implemented, the only thing missing is the correct context of the feature branch.
Permissions and Security
Pretty much exactly like the existing ones, I suppose.
Extend the existing docs.
Availability & Testing
Free, as the related features are free, as well.
What does success look like, and how can we measure that?
When performing the above steps and not receiving an error message.
What is the type of buyer?
Is this a cross-stage feature?
Links / references
Related to #217018 (closed) and #231352 (closed)