[英]Gitlab Group API returns different values depending on the token used
我正在使用 curl 查詢 Gitlab 組 API。使用 PAT 令牌時得到的結果與使用 CI_JOB_TOKEN 時得到的結果不同。 PAT 令牌返回我有權訪問的所有組,但使用 CI_JOB_TOKEN 返回奇怪的響應。 我讀到 CI_JOB_TOKEN 與運行管道的用戶具有相同的權限。
'curl --header "--header "JOB-TOKEN: $CI_JOB_TOKEN" https://gitlab.com/api/v4/groups"'
返回以下響應,我不知道它是什么。 它不是我的小組之一:
teur-territoires/france-relance/","visibility":"public","share_with_group_lock":false,"require_two_factor_authentication":false,"two_factor_grace_period":48,"project_creation_level":"developer","auto_devops_enabled":null,"subgroup_creation_level":"maintainer","emails_disabled":null,"mentions_disabled":null,"lfs_enabled":true,"default_branch_protection":2,"avatar_url":"https://gitlab.com/uploads/-/system/group/avatar/16026247/france-relance-vert.png","request_access_enabled":true,"full_name":"🇫🇷 France Relance","full_path":"france-relance","created_at":"2022-02-05T20:55:13.007Z","parent_id":null,"ldap_cn":null,"ldap_access":null}]
在使用我的 PAT 令牌運行時,它以正確的格式返回正確的結果:
curl --silent --header "PRIVATE-TOKEN: $MY_PAT_TOKEN" "https://gitlab.com/api/v4/groups"
[
{
"id": xxxxxx,
"web_url": "https://gitlab.com/groups/txxxxest",
"name": "xxxx",
"path": "xxxxx",
"description": "",
"visibility": "private",
"share_with_group_lock": false,
"require_two_factor_authentication": false,
"two_factor_grace_period": 48,
"project_creation_level": "developer",
"auto_devops_enabled": null,
"subgroup_creation_level": "maintainer",
"emails_disabled": null,
"mentions_disabled": null,
"lfs_enabled": true,
"default_branch_protection": 2,
"avatar_url": null,
"request_access_enabled": true,
"full_name": "xxxx",
"full_path": "xxxxx",
"created_at": "2023-01-29T08:41:38.696Z",
"parent_id": null,
"ldap_cn": null,
"ldap_access": null,
"marked_for_deletion_on": null
},
{
"id": xxxxxx,
"web_url": "https://gitlab.com/groups/xxxx",
"name": "xxx",
"path": "xxx",
"description": "",
"visibility": "private",
"share_with_group_lock": false,
"require_two_factor_authentication": false,
"two_factor_grace_period": 48,
"project_creation_level": "developer",
"auto_devops_enabled": null,
"subgroup_creation_level": "maintainer",
"emails_disabled": null,
"mentions_disabled": null,
"lfs_enabled": true,
"default_branch_protection": 2,
"avatar_url": null,
"request_access_enabled": true,
"full_name": "xxxxxn",
"full_path": "xxxxxx",
"created_at": "2023-01-29T13:58:49.800Z",
"parent_id": null,
"ldap_cn": null,
"ldap_access": null
}
我不確定它為什么會表現出這種行為。 如果可以使用 CI_JOB_TOKEN,我不想管理 PAT 令牌
您的 CI 腳本中有錯字
'curl --header "--header "JOB-TOKEN: $CI_JOB_TOKEN" https://gitlab.com/api/v4/groups"'
它應該是:
'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" https://gitlab.com/api/v4/groups"'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.