I have a snippet that I want to use in my gitlab ci across multiple projects.
before_script:
- curl --header "PRIVATE-TOKEN: xxx" https://gitlab.example.com/api/v4/snippets/1
- bash my_script.sh
I tried using the $CI_JOB_TOKEN
resulting in a 401. Is there a way to gain access without creating a user token?
The short answer is NO.CI_JOB_TOKEN
variable used for authenticating with the GitLab Container Registry and downloading dependent repositories [1].
You can create personal and project Snippets, with three visibility levels [2], private, internal and public.
Private snippets are only visible to the snippet creator, so you need a Personal access token (with api scope!!!, and it's not recommended for CI jobs in public/shared projects.
Suggestion:
[1] https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
[2] https://docs.gitlab.com/ee/api/snippets.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With