You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"environment" in data for POST API calls to tasks templates (/api/project/{project_id}/tasks) need to be from type string.
Expected Behavior
"environment" in data for POST API calls to tasks templates (/api/project/{project_id}/tasks) should be JSON.
Extra info
I have a task template with a required survey variable "myvar" looks like this in WebGUI:
If I want to run this template I will be asked for the survey var. I runs successful. In the request to the semaphore server I can see the request json data: {"template_id":32,"environment":"{\"myvar\":\"MyValue\"}","project_id":4}
Note: behind "environment" it if a string-formated JSON part.
In WebUI everything works fine (Response code 201).
Now I try to do the same via an API call within an ansible play with "uri" module:
The part behind is environment is interpreted as string, not json.
In the next step I want to have a variable for "MyValue" in ansible, so the "environment" line from above (the ansible play) is changed to this:
environment: "{\"myvar\":\"{{ value_var }} \"}"
where the value of variable "value_var" is "MyValue".
I the webserver request I investigated I can see the sent json data looks like this: {"template_id": 32, "environment": {"myvar": "MyValue"}}
But the response code is 404! It is not working.
jinja2 does something with that, so that the part behind environment is interpreted as json and not as string. And can't be changed. So, if it would be possible to paste JSON in environment and not a string it should work.
The text was updated successfully, but these errors were encountered:
Semaphore version: v2.9.64
Observed Behavior
"environment" in data for POST API calls to tasks templates (/api/project/{project_id}/tasks) need to be from type string.
Expected Behavior
"environment" in data for POST API calls to tasks templates (/api/project/{project_id}/tasks) should be JSON.
Extra info
I have a task template with a required survey variable "myvar" looks like this in WebGUI:
If I want to run this template I will be asked for the survey var. I runs successful. In the request to the semaphore server I can see the request json data:
{"template_id":32,"environment":"{\"myvar\":\"MyValue\"}","project_id":4}
Note: behind "environment" it if a string-formated JSON part.
In WebUI everything works fine (Response code 201).
Now I try to do the same via an API call within an ansible play with "uri" module:
As you can see the survey var (in "environment") needs to be escaped, but it is working (Response code 201).
In the webserver request I investigated I can see the sent json data looks like this:
{"template_id": 32, "environment": "{\"myvar\":\"MyValue\"}"}
The part behind is environment is interpreted as string, not json.
In the next step I want to have a variable for "MyValue" in ansible, so the "environment" line from above (the ansible play) is changed to this:
environment: "{\"myvar\":\"{{ value_var }} \"}"
where the value of variable "value_var" is "MyValue".
I the webserver request I investigated I can see the sent json data looks like this:
{"template_id": 32, "environment": {"myvar": "MyValue"}}
But the response code is 404! It is not working.
jinja2 does something with that, so that the part behind environment is interpreted as json and not as string. And can't be changed. So, if it would be possible to paste JSON in environment and not a string it should work.
The text was updated successfully, but these errors were encountered: