在哪里可以找到gitlab api的项目ID? [英] where do I find the project id for the gitlab api?
问题描述
我在他们的服务器上使用gitlab.我想通过这样的API下载我最新构建的工件(通过gitlab-ci构建):
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"
在哪里可以找到该项目ID?还是这种使用API的方式不适用于托管的gitlab项目?
Where do I find this project id? Or is this way of using the API not intended for hosted gitlab projects?
休伯特(BW Hubert)
BW Hubert
推荐答案
您可以查询自己拥有的项目:
You can query for your owned projects:
curl -XGET --header "PRIVATE-TOKEN: XXXX" "https://gitlab.com/api/v3/projects/owned"
您将收到每个拥有的项目的JSON:
You will receive JSON with each owned project:
[
{
"id":48,
"description":"",
"default_branch":"master",
"tag_list":[
...
您还可以从项目的触发器配置中获取项目ID,该项目中已经包含一些带有ID的示例代码.
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.
在触发器"页面上:
curl -X POST \
-F token=TOKEN \
-F ref=REF_NAME \
https://<GitLab Installation>/api/v3/projects/<ProjectID>/trigger/builds
这篇关于在哪里可以找到gitlab api的项目ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!