CLI Automation

Hello Team,

I use the last version of importer (1.24). I try to import a junit file with the command :

./testiny-importer-linux automation --app myndd --project XXX --apikey tny_ddd --junit results.xml --environment gitlab --use-server-time --run-title-pattern “mysuperapp 2025-03-25 v2.3.4”

And i got the message :
Import error: Failed to submit because 4 result(s) are associated with an already completed test run

I dont know how to bypass this ?

Ok i achieved to bypass this by removing the --environnment option. I don’t know why. iIt’s ok on my side but if someone can explain that’ll be great :slight_smile:

The error message means that Testiny tried to add the results to an already existing test run, but that test run was already set to “completed”.
Testiny determines which automated test runs the results should be added to by the current environment values, e.g. commit, branch, pipeline ID, … - but only if there are any. So if you run the importer in a non-CI environment (or specify the wrong environment), the environment values may all be empty.

The --environment flag disables automatic environment detection and in your case pins the environment to “gitlab”. If you’re running the importer inside a gitlab pipeline/job, then this is not a problem and the environment values will be correctly filled and used, but otherwise they will be empty.

Additionally, by default, if you import a results file using the Testiny CLI, the created automated test run will be set to completed. So if you import any result file with the same environment values (even if empty), the same run will be used and Testiny will not allow that, because the run is already completed.

What you can do:

  • if you’re running in a CI environment, don’t specify the --environment flag and let the automatic detection do it’s magic
  • if your running locally, e.g. to test things out, you can use the run-fields and field-values parameters to specify unique values for each import and thus create new automated test runs for every import
  • you can also use the --incomplete flag to not close the automated test run after the import. Subsequent imports can then use the same run and results will be added to the test run

For more information have a look at the Automation chapter in the Testiny Docs and the CLI Reference in particular. Thanks!

Best regards,
Alex