我在哪里可以找到 GitLab API 的项目 ID? [英] Where do I find the project ID for the GitLab API?

查看:57
本文介绍了我在哪里可以找到 GitLab API 的项目 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在他们的服务器上使用 GitLab.我想通过这样的 API 下载我最新构建的工件(通过 GitLab CI 构建):

curl --header 私人代币:9koXpg98eAheJpvBs5tK"https://gitlab.com/api/v3/projects/1/builds/8/artifacts"

在哪里可以找到此项目 ID?还是这种使用 API 的方式不适用于托管的 GitLab 项目?

解决方案

您可以查询您拥有的项目:

curl -XGET --header "PRIVATE-TOKEN: XXXX" "https://gitlab.com/api/v3/projects/owned"

您将收到每个拥有的项目的 JSON:

<预><代码>[{身份证":48,描述":"","default_branch":"master",标签列表":[...

<小时>

您还可以从项目中的触发器配置中获取项目 ID,该项目已经有一些带有您 ID 的示例代码.

来自触发器页面:

curl -X POST \-F 代币=代币 \-F ref=REF_NAME \https:///api/v3/projects//trigger/builds

I use GitLab on their servers. I would like to download my latest built artifacts (build via GitLab CI) via the API like this:

curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.com/api/v3/projects/1/builds/8/artifacts"

Where do I find this project ID? Or is this way of using the API not intended for hosted GitLab projects?

解决方案

You can query for your owned projects:

curl -XGET --header "PRIVATE-TOKEN: XXXX" "https://gitlab.com/api/v3/projects/owned"

You will receive JSON with each owned project:

[
  {
    "id":48,
    "description":"",
    "default_branch":"master",
    "tag_list":[
...


You are also able to get the project ID from the triggers configuration in your project which already has some sample code with your ID.

From the Triggers page:

curl -X POST \
     -F token=TOKEN \
     -F ref=REF_NAME \
     https://<GitLab Installation>/api/v3/projects/<ProjectID>/trigger/builds

这篇关于我在哪里可以找到 GitLab API 的项目 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆