'Is it possible to use a private GitLab repo as a remote include in GitLab CI? If so, how?

Given that I have a private repo with this file:

https://gitlab.com/myuser/snippets/-/raw/main/snippets.yml

.my-snippet:
  before_script:
    - one command here...
    - another thing here...

and that I would like to do this in a .gitlab-ci.yml file in a different private repo:

https://gitlab.com/myuser/coderepo/-/raw/main/.gitlab-ci.yml

include:
  remote: https://gitlab.com/myuser/snippets/-/raw/main/snippets.yml

mycijob:
  extends: .my-snippet
  script:
    - does a thing...
    - probably does something else...

How would a person go about such a thing? I gave deploy tokens a stab, but that didn't appear to work when getting a file's raw content. I get a 503. Is this something that's even possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source