Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lksv
Copy link

@lksv lksv commented Aug 9, 2018

No description provided.

'key' => key,
'value' => value
)
end
Copy link
Owner

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.

Copy link
Owner

@NARKOZ NARKOZ left a 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.

@NARKOZ
Copy link
Owner

NARKOZ commented Sep 18, 2018

Kind reminder @lksv

@littldr
Copy link

littldr commented Nov 2, 2018

Any progress here? I've stumbled over the same 'issue' and would love to see this feature merged. :)
Thanks for the good work!

post(
"/projects/#{url_encode project}/pipeline",
query: { ref: ref },
body: JSON.dump(normalized_variables)
Copy link

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?

Copy link
Owner

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.

@NARKOZ
Copy link
Owner

NARKOZ commented Nov 2, 2018

91afbd7

@NARKOZ NARKOZ closed this Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants