Problem to solve
I am trying to create a badge as part of a CI pipeline. My .gitlab-ci.yml
file looks like this.
# .gitlab-ci.yml
stages:
- build
- deploy
job1:
stage: build
script:
- # Your build commands here
job2:
stage: deploy
script:
- # Your deploy commands here
# Requesting a badge via API
- curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" -o badge.svg "https://gitlab.example.com/api/v4/projects/$CI_PROJECT_ID/badges/build?ref=master"
This works if I provide a personal access token, while I get 401 Unauthorized
if I use the CI_JOB_TOKEN
.
Is there a way to authenticate to the gitlab badges API via the CI_JOB_TOKEN, or is access to that API limited to private access tokens?
Thanks
Giulio