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
8ca5c333
Commit
8ca5c333
authored
Aug 18, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend API: Pipeline Schedule Variable
parent
970af996
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
243 additions
and
2 deletions
+243
-2
doc/api/pipeline_schedules.md
doc/api/pipeline_schedules.md
+160
-1
lib/api/entities.rb
lib/api/entities.rb
+2
-1
lib/api/pipeline_schedules.rb
lib/api/pipeline_schedules.rb
+70
-0
spec/fixtures/api/schemas/pipeline_schedule.json
spec/fixtures/api/schemas/pipeline_schedule.json
+11
-0
No files found.
doc/api/pipeline_schedules.md
View file @
8ca5c333
...
...
@@ -84,7 +84,13 @@ curl --header "PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ" "https://gitlab.example.com/
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"https://gitlab.example.com/root"
},
"variables"
:
[
{
"key"
:
"TEST_VARIABLE_1"
,
"value"
:
"TEST_1"
}
]
}
```
...
...
@@ -271,3 +277,156 @@ curl --request DELETE --header "PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ" "https://gi
}
}
```
## Create a new pipeline schedule variable
Create a new variable of a pipeline schedule.
```
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables
```
| Attribute | Type | required | Description |
|---------------|---------|----------|--------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_schedule_id`
| integer | yes | The pipeline schedule id |
|
`key`
| string | yes | The
`key`
of a variable; must have no more than 255 characters; only
`A-Z`
,
`a-z`
,
`0-9`
, and
`_`
are allowed |
|
`value`
| string | yes | The
`value`
of a variable |
```
sh
curl
--request
POST
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
--form
"key=NEW_VARIABLE"
--form
"value=new value"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables"
```
```
json
{
"id"
:
13
,
"description"
:
"Test schedule pipeline"
,
"ref"
:
"master"
,
"cron"
:
"* * * * *"
,
"cron_timezone"
:
"Asia/Tokyo"
,
"next_run_at"
:
"2017-05-19T13:41:00.000Z"
,
"active"
:
true
,
"created_at"
:
"2017-05-19T13:31:08.849Z"
,
"updated_at"
:
"2017-05-19T13:40:17.727Z"
,
"last_pipeline"
:
{
"id"
:
332
,
"sha"
:
"0e788619d0b5ec17388dffb973ecd505946156db"
,
"ref"
:
"master"
,
"status"
:
"pending"
},
"owner"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"https://gitlab.example.com/root"
},
"variables"
:
[
{
"key"
:
"NEW_VARIABLE"
,
"value"
:
"new value"
}
]
}
```
## Edit a pipeline schedule variable
Updates the variable of a pipeline schedule.
```
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
```
| Attribute | Type | required | Description |
|---------------|---------|----------|--------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_schedule_id`
| integer | yes | The pipeline schedule id |
|
`key`
| string | yes | The
`key`
of a variable |
|
`value`
| string | yes | The
`value`
of a variable |
```
sh
curl
--request
PUT
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
--form
"value=updated value"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
```
```
json
{
"id"
:
13
,
"description"
:
"Test schedule pipeline"
,
"ref"
:
"master"
,
"cron"
:
"* * * * *"
,
"cron_timezone"
:
"Asia/Tokyo"
,
"next_run_at"
:
"2017-05-19T13:41:00.000Z"
,
"active"
:
true
,
"created_at"
:
"2017-05-19T13:31:08.849Z"
,
"updated_at"
:
"2017-05-19T13:40:17.727Z"
,
"last_pipeline"
:
{
"id"
:
332
,
"sha"
:
"0e788619d0b5ec17388dffb973ecd505946156db"
,
"ref"
:
"master"
,
"status"
:
"pending"
},
"owner"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"https://gitlab.example.com/root"
},
"variables"
:
[
{
"key"
:
"NEW_VARIABLE"
,
"value"
:
"updated value"
}
]
}
```
## Delete a pipeline schedule variable
Delete the variable of a pipeline schedule.
```
DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
```
| Attribute | Type | required | Description |
|----------------|---------|----------|--------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_schedule_id`
| integer | yes | The pipeline schedule id |
|
`key`
| string | yes | The
`key`
of a variable |
```
sh
curl
--request
DELETE
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
```
```
json
{
"id"
:
13
,
"description"
:
"Test schedule pipeline"
,
"ref"
:
"master"
,
"cron"
:
"* * * * *"
,
"cron_timezone"
:
"Asia/Tokyo"
,
"next_run_at"
:
"2017-05-19T13:41:00.000Z"
,
"active"
:
true
,
"created_at"
:
"2017-05-19T13:31:08.849Z"
,
"updated_at"
:
"2017-05-19T13:40:17.727Z"
,
"last_pipeline"
:
{
"id"
:
332
,
"sha"
:
"0e788619d0b5ec17388dffb973ecd505946156db"
,
"ref"
:
"master"
,
"status"
:
"pending"
},
"owner"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"https://gitlab.example.com/root"
},
"variables"
:
[]
}
```
lib/api/entities.rb
View file @
8ca5c333
...
...
@@ -819,7 +819,7 @@ module API
class
Variable
<
Grape
::
Entity
expose
:key
,
:value
expose
:protected?
,
as: :protected
expose
:protected?
,
as: :protected
,
if:
->
(
entity
,
options
)
{
entity
.
respond_to?
(
protected
?)
}
end
class
Pipeline
<
PipelineBasic
...
...
@@ -840,6 +840,7 @@ module API
class
PipelineScheduleDetails
<
PipelineSchedule
expose
:last_pipeline
,
using:
Entities
::
PipelineBasic
expose
:variables
,
using:
Entities
::
Variable
end
class
EnvironmentBasic
<
Grape
::
Entity
...
...
lib/api/pipeline_schedules.rb
View file @
8ca5c333
...
...
@@ -119,6 +119,76 @@ module API
destroy_conditionally!
(
pipeline_schedule
)
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
end
resource
:variables
,
requirements:
{
pipeline_schedule_id:
%r{[^/]+}
}
do
desc
'Create a new pipeline schedule variable'
do
success
Entities
::
PipelineScheduleDetails
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
requires
:value
,
type:
String
,
desc:
'The value of the variable'
end
post
':id/pipeline_schedules/:pipeline_schedule_id/variables'
do
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
variable_params
=
declared_params
(
include_missing:
false
)
variable
=
pipeline_schedule
.
variables
.
create
(
variable_params
)
if
variable
.
persisted?
present
variable
,
with:
Entities
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Edit a pipeline schedule variable'
do
success
Entities
::
PipelineScheduleDetails
end
params
do
optional
:key
,
type:
String
,
desc:
'The key of the variable'
optional
:value
,
type:
String
,
desc:
'The value of the variable'
end
put
':id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
variable
=
pipeline_schedule
.
variables
.
find_by
(
key:
params
[
:key
])
not_found!
(
'Variable'
)
unless
variable
if
variable
.
update
(
declared_params
(
include_missing:
false
))
present
variable
,
with:
Entities
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Delete a pipeline schedule variable'
do
success
Entities
::
PipelineScheduleDetails
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
end
delete
':id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
variable
=
pipeline_schedule
.
variables
.
find_by
(
key:
params
[
:key
])
not_found!
(
'Variable'
)
unless
variable
status
:accepted
present
variable
,
with:
Entities
::
Variable
end
end
end
helpers
do
...
...
spec/fixtures/api/schemas/pipeline_schedule.json
View file @
8ca5c333
...
...
@@ -31,6 +31,17 @@
"web_url"
:
{
"type"
:
"uri"
}
},
"additionalProperties"
:
false
},
"variables"
:
{
"type"
:
[
"array"
,
"null"
],
"items"
:
{
"type"
:
[
"object"
,
"null"
],
"properties"
:
{
"key"
:
{
"type"
:
"string"
},
"value"
:
{
"type"
:
"string"
}
},
"additionalProperties"
:
false
}
}
},
"required"
:
[
...
...
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