Skip to content

Trigger variables ignored with v4 API #333

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

Closed
jeromerobert opened this issue Oct 3, 2017 · 1 comment
Closed

Trigger variables ignored with v4 API #333

jeromerobert opened this issue Oct 3, 2017 · 1 comment

Comments

@jeromerobert
Copy link
Contributor

Since I switched to v4 API, the variables I pass to triggers are ignored. Here is a sample of code:

from httplib import HTTPConnection
HTTPConnection.debuglevel = 2
my_project.trigger_pipeline('gitlabci', 'XXXXX', {'variables[GITLAB_TEST]': 'ThisIsATest'})

From httplib debug output it's equivalent to:

curl --request POST https://gitlab.com/api/v4/projects/XXXX/trigger/pipeline -H "Content-Type: application/json" -d '{"token": "XXXXX", "ref": "gitlabci", "variables[GITLAB_TEST]": "ThisIsATest"}'

which also ignore variables. Doing the same without JSON does work:

curl --request POST https://gitlab.com/api/v4/projects/XXXX/trigger/pipeline  --form token=XXXXX --form ref=gitlabci --form "variables[GITLAB_TEST]=ThisIsATest"

Would it be possible that Gitlab expect the JSON payload to have an other structure ?

@jeromerobert
Copy link
Contributor Author

After some trial I found the valid JSON structure:

{
 "token": "XXXXX",
 "ref": "gitlabci",
 "variables": {"GITLAB_TEST": "ThisIsATest"}
}

jeromerobert added a commit to jeromerobert/python-gitlab that referenced this issue Oct 3, 2017
gpocentek pushed a commit that referenced this issue Oct 8, 2017
Fix trigger variables in v4 API

Close #333
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant