Subscribe Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security. Subscribe

How to featch the run id from a milestone name through api

Hi I am new to this testrail and setting up jenkins job to post the test results to testrail run,

We are creating two runs( P0 & P1, P2) with milestone creation. Now i am giving the run id manually every time when I execute the job. I would like to automate this process. So when the release version apks successfully build, the jenkins job generates the version for each release.

Release version number

So I will create the same version as Milestone name as and create runs in this milestone The test results will be uploaded to these runs. Here i would like to get the id through api instead of entering manually.

How to fetch the run IDs from milestone by giving the name.

Thank you.

Hi @harasai,

following your description I’m not sure how you identify the test run id, if you have multiple runs assigned to a milestone.
But to identify the run(s) of a milestone by the milestone name, I would try it this way:

get_milestones to retrieve all milestones for a project. You need to provide the project id and optionally use a filter for open milestones to reduce the list. Iterate trough the list of milestones and check for the name to retrieve the id - don’t forget, the name isn’t unique.

get_runs to retrive a list of runs by providing the project id and the optional filter for the determined milestone id from above.

Now you have a list of runs and you need to identify the one you want to use - see my first point.

Does this sounds reasonable for you?


1 Like

Thank you Karsten for your response and the suggestion. we have unique name for milestones no issues raised while fetch the id by name.

Here i Have question.

We have a master suite which consists of all the test cases within sections and subsections. For automation purpose, I need to create the test run with all P0 and P1 priority test cases through the api instead of choosing include: all. If any test cases added to suit with these priorities will be added to newly created testrun.

Hi @harasai,
you’re welcome.

That sounds quite easy I think.
Unfortunately you cant create a run with a filter (your P0 and P1) for cases on a suite. Would be a nice and useful extension for the endpoint. So, unfortunately you have to provide the list of case id’s.

You can use get_cases to retrieve all the cases for a suite. If your P0 and P1 is stored in the system field “priority_id” you can provide this as a filter directly, otherwise you have to iterate through all the cases and remove the irrelevant.

This list/array of id’s can be passed to add_run. That’s it.

At least, how I would do so…