Custom CICD configuration is not working

Custom gitlab CICD congiguration (gitlab-ci.yml) is not working.

Description

I have a gitlab repo with CICD enabled, i don’t want to keep that gitlab-ci.yml file in my gitlab project directory. I have kept it in another project and i have given the path of that gitlab-ci.yml in the my project’s setting CICD configuration file as per the gitlab documentation available here.

But looks like my gitlab repo is not able to recognise that gitlab-ci.yml file.

Looks like i am missing something while providing the gitlab-ci.yml file location in my current gitlab project repo.

I am looking for some help to fix this issue. Any example will really help me to fix my issue.

Thanks & Regards,
Ankit Goel

Hi All,

Finally i could make it work but only for default branch of a repo but not for any other branches. Below is details of what i tried.

I had one gitlab project repo say repo-1 with gitlab-ci.yml file available in the project root directory and i had another gitlab project repo say repo-2 where i wanted to keep the gitlab-ci.yml from repo-1. So i deleted the gitlab-ci.yml from repo-1 and uploaded/created the same file in repo-2. Now in repo-1 project’s setting → CICD → General → CI/CD configuration file , i have defined the path of gitlab-ci.yml available in repo-2 and then tried to run the pipeline and i found that it is working fine.
I observed that it is only working fine when the gitlab-ci.yml file is available in the default branch (master/main) but when i created another branch and kept the gitlab-ci.yml file there and updated the path in repo-1 as per the gitlab documentation, then it is not working at all. Below is the link for your ref.

I need your help in order to make it work for other branches as well.

Awaiting for your response.

Best Regards,
Ankit Goel

The link you shared specify that it’s introduced in version 12.6. Just to cover all grounds, can you confirm yours is newer?


Admittedly, I’ve never used external files (don’t really when it’s required), but I feel it’d be better if you give more information on the issue. Like what exactly happens when you pass the file location (along with group, project and branch information) will probably be helpful for others to help you, rather than just this statement.

Thanks for responding.

I am at GitLab Enterprise Edition - 15.4.0-ee.

Below is the details of what is working and what is not working.

Working Scenario:

I had one gitlab project repo say repo-1 with gitlab-ci.yml file available in the project root directory in project’s default branch (master branch) and i had another gitlab project repo say repo-2 where i wanted to keep the gitlab-ci.yml from repo-1. So i deleted the gitlab-ci.yml from repo-1 and uploaded/created the same file in repo-2. Now in repo-1 project’s setting → CICD → General → CI/CD configuration file , i have defined the path of gitlab-ci.yml available in repo-2 as shown below and then tried to run the pipeline and i found that it is working fine.

CI/CD configuration file: .gitlab-ci.yml@mygroup/another-project

Non Working Scenario:

In this scenario, i want to do the same as above but instead of using the project’s default branch i.e main branch, i want to use some other branch and i used the CICD configuration file path as follows:

CI/CD configuration file: .gitlab-ci.yml@mygroup/another-project:branch-name

In this case, i observed that i am not able to run the CICD pipeline because the repo is not able to find the gitlab-ci.yml which is available in another project.

Is your “another-project” set as Public for other people to get to?

No, But required people has access to it.

A good test is replacing “branch-name” with a bogus name, not a branch at all. Then you run the pipeline and it should complaint no reference found. Then, you know the reference work, and the issue now moves to the .gitlab-ci.yml.

I had the same issue until I tested with a bogus name as I mentioned above. However, I realized I had included files in my .gitlab-ci.yml and the included lines has hardcoded name of the branch. Once I removed the hardcoded references, it worked.

Wish you luck.