mkdocs-git-committers-plugin-2
mkdocs-git-committers-plugin-2 copied to clipboard
Documentation regarding Gitlab `$CI_JOB_TOKEN` is wrong
Hey!
In the setup, we can find this snippet:
plugins:
- git-committers:
gitlab_repository: 12345678
token: !ENV ["CI_JOB_TOKEN"]
Which in fact does not work using recent Gitlab versions.
The doc about CI_JOB_TOKEN clearly states this:
| Resource | Notes |
|---|---|
| Repositories API | Can access only the GET /projects/:id/repository/changelog endpoint. |
I have tried using a simple CI and
- the CI Job token
- a project access token with the
read_apipermission
like this:
image: python:3.12
pages:
before_script:
- apt-get update && apt-get install -y curl jq
script:
- |
echo "Checking GitLab API access..."
curl "https://[REDACTED]/api/v4/projects/[REDACTED]/repository/commits?path=docs&ref_name=main" -H "JOB-TOKEN: ${CI_JOB_TOKEN}" | jq
- |
echo "Checking GitLab API access..."
curl "https://[REDACTED]/api/v4/projects/[REDACTED]/repository/commits?path=docs&ref_name=main" -H "PRIVATE-TOKEN: ${MKDOCS_GIT_COMMITTERS_APIKEY}" | jq
And here's the output:
$ echo "Checking GitLab API access..." # collapsed multi-line command
Checking GitLab API access...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 35 100 35 0 0 372 0 --:--:-- --:--:-- --:--:-- 376
{
"message": "404 Project Not Found"
}
$ echo "Checking GitLab API access..." # collapsed multi-line command
Checking GitLab API access...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3895 100 3895 0 0 24304 0 --:--:-- --:--:-- --:--:-- 24343
[
{
...
},
{
...
},
{
...
},
{
...
},
{
...
},
{
...
}
]
As you can see, it only works with the project access token.