Skip to content

Commit 0ab7199

Browse files
authored
add to API build trigger doc to show a way to use API on Travis CI Enterprise (#3341)
1 parent 577b655 commit 0ab7199

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

user/triggering-builds.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: Triggering builds with API V3
44
layout: en
55
---
66

7+
## Travis CI Hosted Solution (app.travis-ci.com)
8+
79
Trigger Travis CI builds using the API V3 by sending a POST request to `/repo/{slug|id}/requests`:
810

911
1. Get an API token from your Travis CI [settings page](https://app.travis-ci.com/account/preferences). You'll need the token to authenticate most of these API requests.
@@ -12,7 +14,7 @@ Trigger Travis CI builds using the API V3 by sending a POST request to `/repo/{s
1214
to get your API token:
1315

1416
```
15-
travis login --com
17+
travis login --com --github-token YOUR_GITHUB_TOKEN
1618
travis token --com
1719
```
1820

@@ -23,7 +25,7 @@ Trigger Travis CI builds using the API V3 by sending a POST request to `/repo/{s
2325
```bash
2426
body='{
2527
"request": {
26-
"branch":"master"
28+
"branch":"master",
2729
"sha":"bf944c952724dd2f00ff0c466a5e217d10f73bea"
2830
}}'
2931

@@ -117,6 +119,51 @@ Trigger Travis CI builds using the API V3 by sending a POST request to `/repo/{s
117119

118120
{{ site.data.snippets.ghlimit }}
119121

122+
## Travis CI Enterprise
123+
124+
Trigger Travis CI builds using the API on your Travis CI Enterprise instance by sending a POST request to `/repo/{slug|id}/requests`:
125+
126+
1. Get an API token from your Travis CI Enterprise at https://PLATFORM_URL/account/preferences. You'll need the token to authenticate most of these API requests.
127+
128+
You can also use the Travis CI [command line client](https://github.com/travis-ci/travis.rb#travis-ci-and-travis-ci-enterprise)
129+
to get your API token:
130+
131+
```
132+
travis login -X --github-token YOUR_GITHUB_TOKEN
133+
travis token -X
134+
```
135+
136+
2. Send a request to the API. This example shell script sends a POST request to
137+
`/repo/travis-ci/tcie-demo/requests` to trigger a build of a specific
138+
commit (omit `sha` for most recent) of the master branch of the `travis-ci/tcie-demo` repository:
139+
140+
```bash
141+
body='{
142+
"request": {
143+
"branch":"master",
144+
"sha":"bf944c952724dd2f00ff0c466a5e217d10f73bea"
145+
}}'
146+
147+
curl -s -X POST \
148+
-H "Content-Type: application/json" \
149+
-H "Accept: application/json" \
150+
-H "Travis-API-Version: 3" \
151+
-H "Authorization: token xxxxxx" \
152+
-d "$body" \
153+
https://PLATFORM_URL/api/repo/travis-ci%2Ftcie-demo/requests
154+
```
155+
156+
> The %2F in the request URL is required so that the owner and repository
157+
name in the repository slug are interpreted as a single URL segment.
158+
> The `PLATFORM_URL` is the endpoint where your Travis CI Enterprise instance is reachable.
159+
160+
161+
The build uses the `.travis.yml` file in the master branch, but you can add to
162+
or override configuration, or change the commit message. Overriding any section
163+
(like `script` or `env`) overrides the full section, the contents of the
164+
`.travis.yml` file present in the repository is *not* merged with the values contained in the request.
165+
166+
120167
## Customizing the commit message
121168

122169
You can specify a commit message in the request body:

0 commit comments

Comments
 (0)