访问Gitlab API

设置Token

点击你的头像选Settings

访问Gitlab API_第1张图片

之后测试版本接口,加入刚才创建的Access Token:

访问Gitlab API_第2张图片

然后需要注意有个base-url,我这里是api/v4访问时要在路径前面加上。

获取一个项目的全部分支

url

GET /projects/root%2Fmaven-sample/repository/branches

response

[
    {
        "name": "develop",
        "commit": {
            "id": "5ca9e9395a2f053be4de1251909f09e0ea90c3f8",  // lastest commit id
            "short_id": "5ca9e939",   
            "created_at": "2020-06-23T18:35:28.000+00:00",
            "parent_ids": null,
            "title": "Add README.md",   // lastest commit msg
            "message": "Add README.md",
            "author_name": "Administrator",
            "author_email": "[email protected]",
            "authored_date": "2020-06-23T18:35:28.000+00:00",
            "committer_name": "Administrator",
            "committer_email": "[email protected]",
            "committed_date": "2020-06-23T18:35:28.000+00:00",
            "web_url": "http://192.168.124.37/root/maven-sample/-/commit/5ca9e9395a2f053be4de1251909f09e0ea90c3f8"
        },
        "merged": false,
        "protected": false,
        "developers_can_push": false,
        "developers_can_merge": false,
        "can_push": true,
        "default": false
    }
]

Refernece List

1`. https://docs.gitlab.com/ee/api/commits.html#list-repository-commits

你可能感兴趣的:(Git)