-
-
Notifications
You must be signed in to change notification settings - Fork 400
Allow to pass variables to create_pipeline #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,9 +38,21 @@ def pipeline(project, id) | |
| # | ||
| # @param [Integer, String] project The ID or name of a project. | ||
| # @param [String] ref Reference to commit. | ||
| # @param [Hash] variables A variables pased to pipeline. | ||
| # @return [Gitlab::ObjectifiedHash] The pipelines changes. | ||
| def create_pipeline(project, ref) | ||
| post("/projects/#{url_encode project}/pipeline?ref=#{ref}") | ||
| def create_pipeline(project, ref, variables = {}) | ||
| normalized_variables = variables.each_with_object([]) do |(key, value), res| | ||
| res.push( | ||
| 'key' => key, | ||
| 'value' => value | ||
| ) | ||
| end | ||
|
|
||
| post( | ||
| "/projects/#{url_encode project}/pipeline", | ||
| query: { ref: ref }, | ||
| body: JSON.dump(normalized_variables) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've played around with this change and noticed that it does not work as expected. The problem is, that the API is missing the name of the parameter ( The following code fixes these issues: def create_pipeline(project, ref, variables = {})
# This is necessary, cause the API expects an array with objects (with `key` and `value` keys) <_<
normalized_variables = variables.each_with_object([]) do |(key, value), res|
res.push(key: key, value: value)
end
post(
"/projects/#{url_encode project}/pipeline",
query: { ref: ref },
body: { variables: normalized_variables },
)
end@NARKOZ do you prefer that this MR gets updated, or should I open another MR with this fix?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @littldr please open a new one. |
||
| ) | ||
| end | ||
|
|
||
| # Cancels a pipeline. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let variables be a string. We don't need this conversion logic in API wrapper.