问题描述
从星期一开始,我无法使用来自 gitlab 的 lint CI API,这里记录了 https://docs.gitlab.com/ee/api/lint.html#validate-the-ci-yaml-configuration
我正在开发一个自托管的 gitlab,我们将 gitlab 更新到最新版本 (13.8.4)。
我注意到文档在 13.8 和 13.9 之间发生了变化,他们提到
访问此端点需要身份验证。
所以我尝试生成一个具有完全访问权限的个人访问令牌(我是管理员),但我仍然收到 401。
这是我的尝试:
$ curl --header "Content-Type: application/json" --header "PRIVATE-TOKEN: P3r50Na1t0k3N" "https://my-domain.artips.fr/api/v4/ci/lint" --data '{"content": "{ \"image\": \"ruby:2.6\",\"services\": [\"postgres\"],\"before_script\": [\"bundle install\",\"bundle exec rake db:create\"],\"variables\": {\"DB_NAME\": \"postgres\"},\"types\": [\"test\",\"deploy\",\"notify\"],\"rspec\": { \"script\": \"rake spec\",\"tags\": [\"ruby\",\"postgres\"],\"only\": [\"branches\"]}}"}'
# Result : {"message":"401 Unauthorized"}
# Other try
$ curl -X POST --header "Content-Type: application/json" --header "PRIVATE-TOKEN: P3r50Na1t0k3N" "https:///my-domain.artips.fr/api/v4/ci/lint" --data '{"content": "{ \"image\": \"ruby:2.6\",\"only\": [\"branches\"]}}"}'
# same result: {"message":"401 Unauthorized"}
有人遇到过同样的问题吗?
提前致谢
武士
解决方法
用户令牌的范围必须授予您对 gitlab 实例的 API 的读/写权限(如图所示)。用户不必是管理员。
,有一个关于 CI Lint API 端点的 ongoing issue。当在本地 Gitlab 实例上禁用“注册”时,此端点的身份验证似乎不起作用。我想这个问题会在未来的版本中得到解决。