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
0
Merge Requests
0
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
Léo-Paul Géneau
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
Hide 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:
...
@@ -26,6 +26,7 @@ following locations:
-
[
Open source license templates
](
licenses.md
)
-
[
Open source license templates
](
licenses.md
)
-
[
Namespaces
](
namespaces.md
)
-
[
Namespaces
](
namespaces.md
)
-
[
Notes
](
notes.md
)
(
comments
)
-
[
Notes
](
notes.md
)
(
comments
)
-
[
Pipelines
](
pipelines.md
)
-
[
Projects
](
projects.md
)
including setting Webhooks
-
[
Projects
](
projects.md
)
including setting Webhooks
-
[
Project Access Requests
](
access_requests.md
)
-
[
Project Access Requests
](
access_requests.md
)
-
[
Project Members
](
members.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
...
@@ -503,7 +503,7 @@ module API
end
end
class
Pipeline
<
Grape
::
Entity
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
:user
,
with:
Entities
::
UserBasic
expose
:created_at
,
:updated_at
,
:started_at
,
:finished_at
,
:committed_at
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
...
@@ -12,9 +12,7 @@ describe API::API, api: true do
ref:
project
.
default_branch
)
ref:
project
.
default_branch
)
end
end
before
do
before
{
project
.
team
<<
[
user
,
:master
]
}
project
.
team
<<
[
user
,
:master
]
end
describe
'GET /projects/:id/pipelines '
do
describe
'GET /projects/:id/pipelines '
do
it_behaves_like
'a paginated resources'
do
it_behaves_like
'a paginated resources'
do
...
@@ -28,6 +26,7 @@ describe API::API, api: true do
...
@@ -28,6 +26,7 @@ describe API::API, api: true do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
.
first
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
.
first
[
'id'
]).
to
eq
pipeline
.
id
end
end
end
end
...
@@ -36,6 +35,8 @@ describe API::API, api: true do
...
@@ -36,6 +35,8 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/pipelines"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
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
end
end
end
...
@@ -53,6 +54,8 @@ describe API::API, api: true do
...
@@ -53,6 +54,8 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/123456"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/123456"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
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
end
end
...
@@ -61,6 +64,8 @@ describe API::API, api: true do
...
@@ -61,6 +64,8 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
non_member
)
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
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
end
end
end
...
@@ -80,6 +85,7 @@ describe API::API, api: true do
...
@@ -80,6 +85,7 @@ describe API::API, api: true do
end
.
to
change
{
pipeline
.
builds
.
count
}.
from
(
1
).
to
(
2
)
end
.
to
change
{
pipeline
.
builds
.
count
}.
from
(
1
).
to
(
2
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
build
.
reload
.
retried?
).
to
be
true
end
end
end
end
...
@@ -88,6 +94,8 @@ describe API::API, api: true do
...
@@ -88,6 +94,8 @@ describe API::API, api: true do
post
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/retry"
,
non_member
)
post
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/retry"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
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
end
end
end
...
@@ -118,6 +126,7 @@ describe API::API, api: true do
...
@@ -118,6 +126,7 @@ describe API::API, api: true do
post
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/cancel"
,
reporter
)
post
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/cancel"
,
reporter
)
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
expect
(
pipeline
.
reload
.
status
).
to
eq
(
'pending'
)
end
end
end
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