|
# Runners API
|
|
# Runners API
|
|
## 注册和验证令牌
|
|
## 注册和验证令牌
|
|
|
|
|
|
将 Runner 与 CODE CHINA 连接时需要以下两个令牌(token)
|
|
将 Runner 与 GitCode 连接时需要以下两个令牌(token)
|
|
|
|
|
|
| 令牌 | 描述 |
|
|
| 令牌 | 描述 |
|
|
| --- | --- |
|
|
| --- | --- |
|
|
| 注册令牌 | 用于注册 Runner 的令牌. 可以[通过 CODE CHINA 获得](/docs/ci/runners) |
|
|
| 注册令牌 | 用于注册 Runner 的令牌. 可以[通过 GitCode 获得](/docs/ci/runners) |
|
|
| 认证令牌 | 用于对 Runner 进行身份验证的令牌. 它可以在注册 Runner 时自动获得,也可以通过 Runners API 手动注册时获得|
|
|
| 认证令牌 | 用于对 Runner 进行身份验证的令牌. 它可以在注册 Runner 时自动获得,也可以通过 Runners API 手动注册时获得|
|
|
|
|
|
|
以下是在 Runner 注册中如何使用两个令牌的示例:
|
|
以下是在 Runner 注册中如何使用两个令牌的示例:
|
... | @@ -18,7 +18,7 @@ |
... | @@ -18,7 +18,7 @@ |
|
token = "<authentication_token>"
|
|
token = "<authentication_token>"
|
|
```
|
|
```
|
|
|
|
|
|
然后将 CODE CHINA 和 Runner 连接起来。
|
|
然后将 GitCode 和 Runner 连接起来。
|
|
|
|
|
|
## 已拥有的 runners 列表
|
|
## 已拥有的 runners 列表
|
|
|
|
|
... | @@ -40,7 +40,7 @@ GET /runners?tag_list=tag1,tag2 |
... | @@ -40,7 +40,7 @@ GET /runners?tag_list=tag1,tag2 |
|
| `tag_list` | 字符串数组 | 否 | runners 的标签列表 |
|
|
| `tag_list` | 字符串数组 | 否 | runners 的标签列表 |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/runners"
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/runners"
|
|
```
|
|
```
|
|
|
|
|
|
响应示例:
|
|
响应示例:
|
... | @@ -82,7 +82,7 @@ GET /runners/:id |
... | @@ -82,7 +82,7 @@ GET /runners/:id |
|
| `id` | integer | 是 | runner ID |
|
|
| `id` | integer | 是 | runner ID |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/runners/6"
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/runners/6"
|
|
```
|
|
```
|
|
|
|
|
|
**注意:**响应中的`token`属性[在 GitLab 12.10](https://gitlab.com/gitlab-org/gitlab/-/issues/214320)中已弃用. 并在[GitLab 13.0 中](https://gitlab.com/gitlab-org/gitlab/-/issues/214322)删除.
|
|
**注意:**响应中的`token`属性[在 GitLab 12.10](https://gitlab.com/gitlab-org/gitlab/-/issues/214320)中已弃用. 并在[GitLab 13.0 中](https://gitlab.com/gitlab-org/gitlab/-/issues/214322)删除.
|
... | @@ -142,7 +142,7 @@ PUT /runners/:id |
... | @@ -142,7 +142,7 @@ PUT /runners/:id |
|
| `maximum_timeout` | integer | 否 | 此 Runner 处理作业的最大超时时间 |
|
|
| `maximum_timeout` | integer | 否 | 此 Runner 处理作业的最大超时时间 |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
|
|
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
|
|
```
|
|
```
|
|
|
|
|
|
响应示例:
|
|
响应示例:
|
... | @@ -210,7 +210,7 @@ GET /runners/:id/jobs |
... | @@ -210,7 +210,7 @@ GET /runners/:id/jobs |
|
| `sort` | string | 否 | 按`asc`或`desc`顺序对作业进行排序(默认值: `desc` ) |
|
|
| `sort` | string | 否 | 按`asc`或`desc`顺序对作业进行排序(默认值: `desc` ) |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/runners/1/jobs?status=running"
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/runners/1/jobs?status=running"
|
|
```
|
|
```
|
|
|
|
|
|
响应示例:
|
|
响应示例:
|
... | @@ -304,7 +304,7 @@ GET /projects/:id/runners?tag_list=tag1,tag2 |
... | @@ -304,7 +304,7 @@ GET /projects/:id/runners?tag_list=tag1,tag2 |
|
| `tag_list` | 字符串数组 | 否 | runner 标签列表 |
|
|
| `tag_list` | 字符串数组 | 否 | runner 标签列表 |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/projects/9/runners"
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/projects/9/runners"
|
|
```
|
|
```
|
|
|
|
|
|
响应示例:
|
|
响应示例:
|
... | @@ -348,7 +348,7 @@ POST /projects/:id/runners |
... | @@ -348,7 +348,7 @@ POST /projects/:id/runners |
|
| `runner_id` | integer | 是 | runner ID |
|
|
| `runner_id` | integer | 是 | runner ID |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/projects/9/runners" --form "runner_id=9"
|
|
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/projects/9/runners" --form "runner_id=9"
|
|
```
|
|
```
|
|
|
|
|
|
响应示例:
|
|
响应示例:
|
... | @@ -380,7 +380,7 @@ DELETE /projects/:id/runners/:runner_id |
... | @@ -380,7 +380,7 @@ DELETE /projects/:id/runners/:runner_id |
|
| `runner_id` | integer | 是 | runner ID |
|
|
| `runner_id` | integer | 是 | runner ID |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/projects/9/runners/9"
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/projects/9/runners/9"
|
|
```
|
|
```
|
|
|
|
|
|
## 获取组织中的 runner 列表
|
|
## 获取组织中的 runner 列表
|
... | @@ -402,7 +402,7 @@ GET /groups/:id/runners?tag_list=tag1,tag2 |
... | @@ -402,7 +402,7 @@ GET /groups/:id/runners?tag_list=tag1,tag2 |
|
| `tag_list` | 字符串数组 | 否 | runner 标签列表 |
|
|
| `tag_list` | 字符串数组 | 否 | runner 标签列表 |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/groups/9/runners"
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/groups/9/runners"
|
|
```
|
|
```
|
|
|
|
|
|
响应示例:
|
|
响应示例:
|
... | @@ -463,7 +463,7 @@ POST /runners |
... | @@ -463,7 +463,7 @@ POST /runners |
|
| `maximum_timeout` | integer | 否 | 此 Runner 处理作业的最大超时时间 |
|
|
| `maximum_timeout` | integer | 否 | 此 Runner 处理作业的最大超时时间 |
|
|
|
|
|
|
```
|
|
```
|
|
curl --request POST "https://codechina.csdn.net/api/v4/runners" --form "token=<registration_token>" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
|
|
curl --request POST "https://gitcode.net/api/v4/runners" --form "token=<registration_token>" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
|
|
```
|
|
```
|
|
|
|
|
|
响应:
|
|
响应:
|
... | @@ -501,7 +501,7 @@ DELETE /runners/:id |
... | @@ -501,7 +501,7 @@ DELETE /runners/:id |
|
| `id` | integer | 是 | runner 的ID。在`项目设置 > CI/CD`下展开 Runners后可见,在 Remove Runner 按钮下方,是一个以 #号 开头的 ID,例如,`#6`。|
|
|
| `id` | integer | 是 | runner 的ID。在`项目设置 > CI/CD`下展开 Runners后可见,在 Remove Runner 按钮下方,是一个以 #号 开头的 ID,例如,`#6`。|
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/runners/6"
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitcode.net/api/v4/runners/6"
|
|
```
|
|
```
|
|
|
|
|
|
### 通过认证令牌删除 runner
|
|
### 通过认证令牌删除 runner
|
... | @@ -517,7 +517,7 @@ DELETE /runners |
... | @@ -517,7 +517,7 @@ DELETE /runners |
|
| `token` | string | 是 | runner 的认证令牌 |
|
|
| `token` | string | 是 | runner 的认证令牌 |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --request DELETE "https://codechina.csdn.net/api/v4/runners" \
|
|
curl --request DELETE "https://gitcode.net/api/v4/runners" \
|
|
--form "token=<authentication_token>"
|
|
--form "token=<authentication_token>"
|
|
```
|
|
```
|
|
|
|
|
... | @@ -540,7 +540,7 @@ POST /runners/verify |
... | @@ -540,7 +540,7 @@ POST /runners/verify |
|
| `token` | string | 是 | runner 的认证令牌 |
|
|
| `token` | string | 是 | runner 的认证令牌 |
|
|
|
|
|
|
```bash
|
|
```bash
|
|
curl --request POST "https://codechina.csdn.net/api/v4/runners/verify" --form "token=<authentication_token>"
|
|
curl --request POST "https://gitcode.net/api/v4/runners/verify" --form "token=<authentication_token>"
|
|
```
|
|
```
|
|
|
|
|
|
响应:
|
|
响应:
|
... | | ... | |