标签:调用 gitlab 接口 token https gl com projects
1.获取用户token
按需填写信息,然后点击创建token.
保存下token.
2.通过python第三方包gitlab调用接口
2.1 链接方式
import gitlab # anonymous read-only access for public resources (GitLab.com) gl = gitlab.Gitlab() # anonymous read-only access for public resources (self-hosted GitLab instance) gl = gitlab.Gitlab('https://gitlab.example.com') # private token or personal token authentication (GitLab.com) gl = gitlab.Gitlab(private_token='JVNSESs8EwWRx5yDxM5q') # private token or personal token authentication (self-hosted GitLab instance) (这里用这种即可) gl = gitlab.Gitlab(url='https://gitlab.example.com', private_token='JVNSESs8EwWRx5yDxM5q') # oauth token authentication gl = gitlab.Gitlab('https://gitlab.example.com', oauth_token='my_long_token_here') # job token authentication (to be used in CI) # bear in mind the limitations of the API endpoints it supports: # https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html import os gl = gitlab.Gitlab('https://gitlab.example.com', job_token=os.environ['CI_JOB_TOKEN']) # Define your own custom user agent for requests gl = gitlab.Gitlab('https://gitlab.example.com', user_agent='my-package/1.0.0') # make an API request to create the gl.user object. This is mandatory if you # use the username/password authentication - not required for token authentication, # and will not work with job tokens. gl.auth()
2.2 调用demo
# List all projects (default 20) projects = gl.projects.list(all=True) # Archived projects projects = gl.projects.list(archived=1) # Limit to projects with a defined visibility projects = gl.projects.list(visibility='public') # List owned projects projects = gl.projects.list(owned=True) # List starred projects projects = gl.projects.list(starred=True) # Search projects projects = gl.projects.list(search='keyword')
2.3 授人以鱼不如授人以渔
最佳文档:https://python-gitlab.readthedocs.io/en/stable/index.html
3.通过原生接口访问
3.1 直接调用
#获取所有project https://gitlab.example.com/api/v4/projects?private_token=xxxxxxxxx #获取指定条件的MR https://gitlab.xiaopeng.us/api/v4/merge_requests?per_page=100&milestone=某某&state=opened&private_token=xxxxxxxx
3.2 授人以鱼不如授人以渔
最佳文档:https://docs.gitlab.com/ee/api/projects.html
4.go调用接口
待补充
标签:调用,gitlab,接口,token,https,gl,com,projects 来源: https://www.cnblogs.com/CGCong/p/16519731.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。