Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e74affcf
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e74affcf
编写于
12月 25, 2015
作者:
A
Achilleas Pipinellis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add images and examples
上级
aafd7ce8
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
95 addition
and
2 deletion
+95
-2
doc/ci/triggers/README.md
doc/ci/triggers/README.md
+95
-2
doc/ci/triggers/img/builds_page.png
doc/ci/triggers/img/builds_page.png
+0
-0
doc/ci/triggers/img/trigger_single_build.png
doc/ci/triggers/img/trigger_single_build.png
+0
-0
doc/ci/triggers/img/trigger_variables.png
doc/ci/triggers/img/trigger_variables.png
+0
-0
doc/ci/triggers/img/triggers_page.png
doc/ci/triggers/img/triggers_page.png
+0
-0
未找到文件。
doc/ci/triggers/README.md
浏览文件 @
e74affcf
...
...
@@ -2,10 +2,103 @@
_**Note:** This feature was [introduced][ci-229] in GitLab CE 7.14_
Triggers can be used to force a rebuild of a specific branch
or tag with an API
call.
Triggers can be used to force a rebuild of a specific branch
, tag or commit,
with an API
call.
## Add a trigger
You can add a new trigger by going to your project's
**Settings > Triggers**
.
The
**Add trigger**
button will create a new token which you can then use to
trigger a rebuild of this particular project.
Once at least one trigger is created, on the
**Triggers**
page you will find
some descriptive information on how you can
Every new trigger you create, gets assigned a different token which you can
then use inside your scripts or
`.gitlab-ci.yml`
. You also have a nice
overview of the time the triggers were last used.
![
Triggers page overview
](
img/triggers_page.png
)
## Revoke a trigger
You can revoke a trigger any time by going at your project's
**Settings > Triggers**
and hitting the
**Revoke**
button. The action is
irreversible.
## Trigger a build
To trigger a build you need to send a
`POST`
request to GitLab's API endpoint:
```
POST /projects/:id/trigger/builds
```
The required parameters are the trigger's
`token`
and the Git
`ref`
on which
the trigger will be performed. Valid refs are the branch, the tag or the commit
SHA. The
`:id`
of a project can be found by
[
querying the API
](
../api/projects.md
)
or by visiting the
**Triggers**
page which provides self-explanatory examples.
When a rebuild is triggered, the information is exposed in GitLab's UI under
the
**Builds**
page and the builds are marked as
`triggered`
.
![
Marked rebuilds as triggered on builds page
](
img/builds_page.png
)
---
You can see which trigger caused the rebuild by visiting the single build page.
The token of the trigger is exposed in the UI as you can see from the image
below.
![
Marked rebuilds as triggered on a single build page
](
img/trigger_single_build.png
)
---
See the
[
Examples
](
#examples
)
section for more details on how to actually
trigger a rebuild.
## Pass build variables to a trigger
You can pass any number of arbitrary variables in the trigger API call and they
will be available in GitLab CI so that they can be used in your
`.gitlab-ci.yml`
file. The parameter is of the form:
```
variables[key]=value
```
This information is also exposed in the UI.
![
Build variables in UI
](
img/trigger_variables.png
)
---
See the
[
Examples
](
#examples
)
section below for more details.
## Examples
Using cURL you can trigger a rebuild with minimal effort, for example:
```
bash
curl
-X
POST
\
-F
token
=
TOKEN
\
-F
ref
=
master
\
https://gitlab.com/api/v3/projects/9/trigger/builds
```
In this case, the project with ID
`9`
will get rebuilt on
`master`
branch.
You can also use triggers in your
`.gitlab-ci.yml`
. Let's say that you have
two projects, A and B, and you want to trigger a rebuild on the
`master`
branch of project B whenever a tag on project A is created.
```
yaml
build_docs
:
stage
:
deploy
script
:
-
"
curl
-X
POST
-F
token=TOKEN
-F
ref=master
https://gitlab.com/api/v3/projects/9/trigger/builds"
only
:
-
tags
```
[
ci-229
]:
https://gitlab.com/gitlab-org/gitlab-ci/merge_requests/229
doc/ci/triggers/img/builds_page.png
0 → 100644
浏览文件 @
e74affcf
38.8 KB
doc/ci/triggers/img/trigger_single_build.png
0 → 100644
浏览文件 @
e74affcf
2.8 KB
doc/ci/triggers/img/trigger_variables.png
0 → 100644
浏览文件 @
e74affcf
5.3 KB
doc/ci/triggers/img/triggers_page.png
0 → 100644
浏览文件 @
e74affcf
15.5 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录