Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
df5661b6
Commit
df5661b6
authored
Aug 17, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs on API for pipelines, plus minor fixes
parent
de7b8e51
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
221 additions
and
4 deletions
+221
-4
doc/api/README.md
doc/api/README.md
+1
-0
doc/api/pipelines.md
doc/api/pipelines.md
+207
-0
lib/api/entities.rb
lib/api/entities.rb
+1
-1
spec/requests/api/pipelines_spec.rb
spec/requests/api/pipelines_spec.rb
+12
-3
No files found.
doc/api/README.md
View file @
df5661b6
...
...
@@ -26,6 +26,7 @@ following locations:
-
[
Open source license templates
](
licenses.md
)
-
[
Namespaces
](
namespaces.md
)
-
[
Notes
](
notes.md
)
(
comments
)
-
[
Pipelines
](
pipelines.md
)
-
[
Projects
](
projects.md
)
including setting Webhooks
-
[
Project Access Requests
](
access_requests.md
)
-
[
Project Members
](
members.md
)
...
...
doc/api/pipelines.md
0 → 100644
View file @
df5661b6
# Pipelines API
## List project pipelines
> [Introduced][ce-5837] in GitLab 8.11
```
GET /projects/:id/pipelines
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
|
`id`
| integer | yes | The ID of a project |
```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/pipelines"
```
Example of response
```
json
[
{
"id"
:
47
,
"status"
:
"pending"
,
"ref"
:
"new-pipeline"
,
"sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"before_sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"tag"
:
false
,
"yaml_errors"
:
null
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"created_at"
:
"2016-08-16T10:23:19.007Z"
,
"updated_at"
:
"2016-08-16T10:23:19.216Z"
,
"started_at"
:
null
,
"finished_at"
:
null
,
"committed_at"
:
null
,
"duration"
:
null
},
{
"id"
:
48
,
"status"
:
"pending"
,
"ref"
:
"new-pipeline"
,
"sha"
:
"eb94b618fb5865b26e80fdd8ae531b7a63ad851a"
,
"before_sha"
:
"eb94b618fb5865b26e80fdd8ae531b7a63ad851a"
,
"tag"
:
false
,
"yaml_errors"
:
null
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"created_at"
:
"2016-08-16T10:23:21.184Z"
,
"updated_at"
:
"2016-08-16T10:23:21.314Z"
,
"started_at"
:
null
,
"finished_at"
:
null
,
"committed_at"
:
null
,
"duration"
:
null
}
]
```
## Get a single pipeline
> [Introduced][ce-5837] in GitLab 8.11
```
GET /projects/:id/pipelines/:pipeline_id
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
|
`id`
| integer | yes | The ID of a project |
|
`pipeline_id`
| integer | yes | The ID of a pipeline |
```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/pipeline/46"
```
Example of response
```
json
{
"id"
:
46
,
"status"
:
"success"
,
"ref"
:
"master"
,
"sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"before_sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"tag"
:
false
,
"yaml_errors"
:
null
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"created_at"
:
"2016-08-11T11:28:34.085Z"
,
"updated_at"
:
"2016-08-11T11:32:35.169Z"
,
"started_at"
:
null
,
"finished_at"
:
"2016-08-11T11:32:35.145Z"
,
"committed_at"
:
null
,
"duration"
:
null
}
```
## Retry failed builds in a pipeline
> [Introduced][ce-5837] in GitLab 8.11
```
POST /projects/:id/pipelines/:pipeline_id/retry
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
|
`id`
| integer | yes | The ID of a project |
|
`pipeline_id`
| integer | yes | The ID of a pipeline |
```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/pipelines/46/retry"
```
Response:
```
json
{
"id"
:
46
,
"status"
:
"pending"
,
"ref"
:
"master"
,
"sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"before_sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"tag"
:
false
,
"yaml_errors"
:
null
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"created_at"
:
"2016-08-11T11:28:34.085Z"
,
"updated_at"
:
"2016-08-11T11:32:35.169Z"
,
"started_at"
:
null
,
"finished_at"
:
"2016-08-11T11:32:35.145Z"
,
"committed_at"
:
null
,
"duration"
:
null
}
```
## Cancel a pipelines builds
> [Introduced][ce-5837] in GitLab 8.11
```
POST /projects/:id/pipelines/:pipeline_id/cancel
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
|
`id`
| integer | yes | The ID of a project |
|
`pipeline_id`
| integer | yes | The ID of a pipeline |
```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/pipelines/46/cancel"
```
Response:
```
json
{
"id"
:
46
,
"status"
:
"canceled"
,
"ref"
:
"master"
,
"sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"before_sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"tag"
:
false
,
"yaml_errors"
:
null
,
"user"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"created_at"
:
"2016-08-11T11:28:34.085Z"
,
"updated_at"
:
"2016-08-11T11:32:35.169Z"
,
"started_at"
:
null
,
"finished_at"
:
"2016-08-11T11:32:35.145Z"
,
"committed_at"
:
null
,
"duration"
:
null
}
```
[
ce-5837
]:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5837
lib/api/entities.rb
View file @
df5661b6
...
...
@@ -503,7 +503,7 @@ module API
end
class
Pipeline
<
Grape
::
Entity
expose
:status
,
:ref
,
:sha
,
:before_sha
,
:tag
,
:yaml_errors
expose
:
id
,
:
status
,
:ref
,
:sha
,
:before_sha
,
:tag
,
:yaml_errors
expose
:user
,
with:
Entities
::
UserBasic
expose
:created_at
,
:updated_at
,
:started_at
,
:finished_at
,
:committed_at
...
...
spec/requests/api/pipelines_spec.rb
View file @
df5661b6
...
...
@@ -12,9 +12,7 @@ describe API::API, api: true do
ref:
project
.
default_branch
)
end
before
do
project
.
team
<<
[
user
,
:master
]
end
before
{
project
.
team
<<
[
user
,
:master
]
}
describe
'GET /projects/:id/pipelines '
do
it_behaves_like
'a paginated resources'
do
...
...
@@ -28,6 +26,7 @@ describe API::API, api: true do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
.
first
[
'id'
]).
to
eq
pipeline
.
id
end
end
...
...
@@ -36,6 +35,8 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Project Not Found'
expect
(
json_response
).
not_to
be_an
Array
end
end
end
...
...
@@ -53,6 +54,8 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/123456"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Not found'
expect
(
json_response
[
'id'
]).
to
be
nil
end
end
...
...
@@ -61,6 +64,8 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Project Not Found'
expect
(
json_response
[
'id'
]).
to
be
nil
end
end
end
...
...
@@ -80,6 +85,7 @@ describe API::API, api: true do
end
.
to
change
{
pipeline
.
builds
.
count
}.
from
(
1
).
to
(
2
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
build
.
reload
.
retried?
).
to
be
true
end
end
...
...
@@ -88,6 +94,8 @@ describe API::API, api: true do
post
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/retry"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Project Not Found'
expect
(
json_response
[
'id'
]).
to
be
nil
end
end
end
...
...
@@ -118,6 +126,7 @@ describe API::API, api: true do
post
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/cancel"
,
reporter
)
expect
(
response
).
to
have_http_status
(
403
)
expect
(
pipeline
.
reload
.
status
).
to
eq
(
'pending'
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment