-
-
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
Conversation
| 'key' => key, | ||
| 'value' => value | ||
| ) | ||
| end |
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.
NARKOZ
left a comment
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.
Thanks. I've left a comment. Also CI build for linting needs fixing.
|
Kind reminder @lksv |
|
Any progress here? I've stumbled over the same 'issue' and would love to see this feature merged. :) |
| 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 comment
The 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 (variables=... see https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline). Furthermore this gem sets the Content-Type header to x-www-form-urlencoded so the server does not understand the json structure which is sent in the body of the request.
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?
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.
@littldr please open a new one.
No description provided.