346.md 4.3 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
# Pipeline triggers API

> 原文:[https://docs.gitlab.com/ee/api/pipeline_triggers.html](https://docs.gitlab.com/ee/api/pipeline_triggers.html)

*   [List project triggers](#list-project-triggers)
*   [Get trigger details](#get-trigger-details)
*   [Create a project trigger](#create-a-project-trigger)
*   [Update a project trigger](#update-a-project-trigger)
*   [Remove a project trigger](#remove-a-project-trigger)

# Pipeline triggers API[](#pipeline-triggers-api "Permalink")

您可以阅读有关[通过 API 触发管道的](../ci/triggers/README.html)更多信息.

## List project triggers[](#list-project-triggers "Permalink")

获取项目的构建触发器的列表.

```
GET /projects/:id/triggers 
```

| Attribute | Type | required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/triggers" 
```

```
[  {  "id":  10,  "description":  "my trigger",  "created_at":  "2016-01-07T09:53:58.235Z",  "last_used":  null,  "token":  "6d056f63e50fe6f8c5f8f4aa10edb7",  "updated_at":  "2016-01-07T09:53:58.235Z",  "owner":  null  }  ] 
```

## Get trigger details[](#get-trigger-details "Permalink")

获取项目构建触发器的详细信息.

```
GET /projects/:id/triggers/:trigger_id 
```

| Attribute | Type | required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `trigger_id` | integer | yes | 触发 ID |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/triggers/5" 
```

```
{  "id":  10,  "description":  "my trigger",  "created_at":  "2016-01-07T09:53:58.235Z",  "last_used":  null,  "token":  "6d056f63e50fe6f8c5f8f4aa10edb7",  "updated_at":  "2016-01-07T09:53:58.235Z",  "owner":  null  } 
```

## Create a project trigger[](#create-a-project-trigger "Permalink")

为项目创建触发器.

```
POST /projects/:id/triggers 
```

| Attribute | Type | required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `description` | string | yes | 触发名称 |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form description="my description" "https://gitlab.example.com/api/v4/projects/1/triggers" 
```

```
{  "id":  10,  "description":  "my trigger",  "created_at":  "2016-01-07T09:53:58.235Z",  "last_used":  null,  "token":  "6d056f63e50fe6f8c5f8f4aa10edb7",  "updated_at":  "2016-01-07T09:53:58.235Z",  "owner":  null  } 
```

## Update a project trigger[](#update-a-project-trigger "Permalink")

更新项目的触发器.

```
PUT /projects/:id/triggers/:trigger_id 
```

| Attribute | Type | required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `trigger_id` | integer | yes | 触发 ID |
| `description` | string | no | 触发名称 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form description="my description" "https://gitlab.example.com/api/v4/projects/1/triggers/10" 
```

```
{  "id":  10,  "description":  "my trigger",  "created_at":  "2016-01-07T09:53:58.235Z",  "last_used":  null,  "token":  "6d056f63e50fe6f8c5f8f4aa10edb7",  "updated_at":  "2016-01-07T09:53:58.235Z",  "owner":  null  } 
```

## Remove a project trigger[](#remove-a-project-trigger "Permalink")

删除项目的生成触发器.

```
DELETE /projects/:id/triggers/:trigger_id 
```

| Attribute | Type | required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `trigger_id` | integer | yes | 触发 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/triggers/5" 
```