install_python_gitlab.sh
pip install python-gitlabget_gitlab_group_id.py
import gitlab
def get_gitlab_group_id(group_name, access_token):
# プライベートトークンで GitLab インスタンスを初期化
gl = gitlab.Gitlab('https://gitlab.com', private_token=access_token)
# 名前でグループを検索
groups = gl.groups.list(search=group_name)
for group in groups:
if group.name == group_name or group.path == group_name:
return group.id
raise ValueError("Group not found")
# 使用例
group_id = get_gitlab_group_id("Protectors of the Footprint Realm", 'glpat-yykIsrTg6RyKcFAvd2os')group_id は整数になります。例: 6604163
この記事が役に立った場合は、TechOverflow での新しい記事の調査と公開を支援するため、「Buy Me a Coffee」でのご支援、または PayPal 経由でのご寄付をご検討ください