Search code examples
gitlabcontinuous-integrationcheckmarxdevsecops

Automatically add a .gitlab-ci.yml file in CI/CD configuration file Settings


I'm completely new with GitLab and I have a scenario where I need to automatically add a .gitlab-ci.yml file to all the project repositories, in order to trigger the pipeline for vulnerability scan in Checkmarx.

I found that we can manually add a path file in a repository by going through the project settings> CI/CD> General Pipelines>CI/CD configuration file .

This is only doable per project repository, but in a scenario where I have more than 100 projects, is there a way to automate and have the .gitlab-ci.yml file set upon the creation of a project repository?


Solution

  • I think there are 3 possibilities to enforece a common/shared CI config file:

    1. Edit Project API and set the ci_config_path value.

    2. Create File in Repository REST API.

    In both those cases, you might need to wrap a call to the respective API a loop that iterates through all groups and subgroups first, to find all projects and their IDs, see:

    Or, brute-forcely iterate up from project ID 1 to a known high ID.


    1. Another alternative is to configure a compliance framework and use the GraphQL API to assign that framework to projects.