Unable to create ansible task dynamically?

Document Reference: https://docs.xebialabs.com/xl-release/8.5.x/rest-docs/#add-a-task-in-a-phase-or-in-another-task

I have been trying to create multiple ansible job tasks dynamically on a for loop via json input. I have followed the above document reference, it’s able to create the xlrelease.UserInputTask but the ansible.LaunchJobTemplate type is throwing error.

RESTEASY003020: Bad arguments passed to public com.xebialabs.xlrelease.domain.Task com.xebialabs.xlrelease.api.v1.TaskApi.addTask(java.lang.String,com.xebialabs.xlrelease.domain.Task,java.lang.Integer)  ( java.lang.String Applications/Folder5bd3abca00a6490bb4046233f0d0c97c/Folder439fb0e71e2643b8ba5e13b4c3910207/Folder63c0c11fec404fffbb487a8c0df6b977/Releasee08ac715239342139f94e674dd0d7ba3/Phase83c9334694074b99926f3fe885cbdf39, com.xebialabs.xlrelease.domain.PythonScript null, null )


$ curl 'http://localhost:5516/api/v1/tasks/Applications/Release162151faba694d03aa3065665cf26f21/Phase520d9bb734c8490cad6818f736da7a5e/tasks' -i -X POST \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
  "id" : "null",
  "type" : "ansible.LaunchJobTemplate",
  "title" : "input task"

Good morning,
please double check:

  • did you use the right authentication ? (for 8.5, your only chance is username / pwd)
  • is ansible.LaunchJobTemplate the right taskname ? it is defined in the synthetic xml of the plugin.
    the plugin provided by us do not have this task type …

Most probably, you get the error because you want to add an ‘extension/plugin tasks’ instead of an ‘core task’.
To add an ‘extension tasks’ you always need the type xlrelease.CustomScriptTask and then add a child property called pythonScript.
See this documentation for more explaination: https://docs.xebialabs.com/xl-release/8.5.x/rest-docs/#task-types.

So in your case this should work:

"id" : "null",
"type" : "xlrelease.CustomScriptTask",
"pythonScript": {
"type": "xldeploy.Deploy",
"id" : "null"
Important General Note: 8.5 is out of support already for some years (Since August 2020):

You can also create the task dynamically from inside release using the Jython API:
A lot of code snippets are here:
1 Like