How to fetch all Builds of a Plan in Bamboo REST API? - rest

I am trying to fetch all builds of a Bamboo plan using the rest API. My plan has more than 25 builds but its giving me only 25 builds.
API URL: https://localhost:8085/rest/api/latest/result/PROJECTKEY-PLANKEY.json
As per the official documentation
The number of resources in returned lists is limited to 25, unless you specify max-result.
Hence, for the workaround, I thought I can fetch build size in first api call and pass size in the second api call as max-results parameter. So that it will give me all builds for a plan. But first API call giving me size 1 whereas the same is working for fetching project size.
API call to get the build size: (Not Working)
https://localhost:8085/rest/api/latest/result/PROJECTKEY-PLANKEY.json?max-results=1
output: size=1, max-result=1 (Whereas plan has 33 builds)
expected output: size=33, max-result=1
https://localhost:8085/rest/api/latest/result/PROJECTKEY-PLANKEY.json?max-results=33
Working API to get the Project Size:
https://localhost:8085/rest/api/latest/project.json?max-results=1
output:size=30, max-result=1
My question here, Can we fetch all BUILDS of a PLAN? As by default it only fetches 25 builds. Or any workaround?
Update: I have posted same problem in Bamboo forum and they found this is an issue in Bamboo REST API.

Unsure whether I am reading it right or there is a typo.
You are adding "s" in max-results at the end, as seen in your http URLs.

Related

How do I use Azure Devops TFS REST API to get older TestRuns of a TestPoint/TestCase/TestSuite?

The API call:
https://dev.azure.com/{organization}/{project}/_apis/test/Plans/{planId}/Suites/{suiteId}/points?api-version=7.0
Returns JSON data with objects "LastTestRun" and "LastTestResult" that contain their Ids. I am trying to find a proper way of getting older (not last) data of TestResults of the given TestPoint using API calls.
I tried the following API call:
https://dev.azure.com/{organization}/{project}/_apis/test/runs?planId=123
That returns me a list of all TestRuns in the given TestPlan. I can loop through the list and make API call for every single TestRun:
https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results
And, then retrieve the TestPointId. The problem is I'm working with large amounts of data, so I'm looping through 7000 API calls and it takes too much time (parallel of course).
I tried calling the last API call with $select so I can retrieve only the TestPointId but it is not supported.
A version of the AzureDevops I am working with: Version Azure DevOps Server 2020 Update 1.2.
Based on your expectation, I have tested as well to get test results with only test point value and tested get the runs of a specific test case in a test suite. Neither succeeded.
Currently there seemed no official API support the test point filter. For this, you may access this URL: https://aka.ms/AzDevOpsIdeas to submit any comments and proposals for future releases and implementations.

Azure Data Factory - REST Pagination rules

I'm trying to pull data from Hubspot to my SQL Server Database through an Azure Data Factory pipeline with the usage of a REST dataset. I have problems setting up the right pagination rules. I've already spent a day on Google and MS guides, but I find it hard to get it working properly.
This is the source API. I am able to connect and pull the first set of 20 rows. It gives an offset which is usable with vidoffset= which is returned in the body.
I need to return the result of vid-offset from the body to the HTTP request. Also the process needs to stop when has-more results in 'false'.
I tried to reproduce the same in my environment and I got the below results:
First I create a linked service with this URL: https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=demo&vidOffset
Then after I created the pagination end condition rule with $.has-more and absolute URL.
For demo purpose, I took sink as a storage account.
The pipeline run success full look at the below image for reference.
For more information refer this Ms Document

How to attach files to Visual Studio Test with Azure DevOps REST API?

TL;DR: How do I relate a release to the tests visible in the Tests tab via the API?
I am running a Release Pipeline which executes tests against the website being deployed. The tests generate files (within my test code) and I want to use the DevOps REST API to attach those files to the Test report associated with the Release.
Note: I am running these tests as smoke tests after release as part of the release pipeline so that I can test the deployed website. This would not be possible as part of the build pipeline.
I can get the release information, but I'm having trouble identifying how to find the related test(s) and attach a file.
Additional: The link in this SO post appears to have been changed and no longer points to the intended page, but now points to the overall documentation for the REST API.
Currently, I believe the process should be:
Get release details
Get test run id
Get test case result id
Create test result attachment
The primary problem is getting the test run id and test case result id from the release information.
I guess I'm a bit late with this, but still.
You are right about the process. Getting Test run ID is possible via accessing logs of corresponding task inside the release. Here's the needed endpoint:
https://{organizationName}.vsrm.visualstudio.com/{projectName}/_apis/release/releases/{releaseID}/environments/{stageID}/deployPhases/{deployPhaseID}/tasks/{taskId}/logs
Please note that test run ID and test IDs will only be available after the test run task is finished.
I'd recommend getting release ID, stage ID and deployment phase ID directly from the release by accessing default variables provided by azure devops (e.g. $(Release.ReleaseId), other ones are easily googled) rather than fetching via API and matching by name, cause it takes time and does not return all releases, only 100 first or smth like that.
After this, you need to get TaskID. I found it possible and applicable looking for that by Task Name. Just fetch the release by it's ID via API and look for task which matches needed name using this endpoint:
https://{organizationName}.vsrm.visualstudio.com/{projectName}/_apis/release/releases/{releaseId}?api-version=5.0
Going through all the deploySteps, deployPhases, deployJobs to get the task name is a bit cumbersome, but possible (I used LINQ).
After getting these 4 base IDs, you are now able to get logs of the Run tests task. In received log I have used a regex to extract test run ID. Then, having test run ID, you can grab the list of test run results:
https://{organizationName}.visualstudio.com/{projectName}/_apis/test/runs/{testRunId}/results
To attach some files to a test, you will need this test's AzDo ID. How can you get it? Well, I can think of mapping the tests by their names (you will need to store a list of those beforehand) and then looping through fetched test results and the stored list. After a match is found, get the respective id, and attach anything you want:
https://{organizationName}.visualstudio.com/{projectName}/_apistest/Runs/{testRunId}/Results/{testId}/attachments?api-version=6.1-preview.1

How do I update the Failed Tests and Pass Rate fields for a VSTS Test Run using the REST API?

The developers at my company are in the process of incorporating VSTS into our testing. I am developing unit tests for our code, using the VSTS Rest API to post the results of the tests, grouped in test runs.
My problem is that I am unable to update the test run to show the number of failed tests and the correct pass rate. My demonstration code uses four unit tests, with 3 passing results and 1 failing result. On the page of test runs, it shows 0 Failed tests and a 0% Pass Rate.
Internet searches haven't yielded any information on how those fields are set or calculated. I've done some searching in the documentation for the REST API in the hopes that I would just need to set a certain field when calling the endpoints. Although the Failed Tests and Pass Rate fields are returned as part of the update call, it doesn't seem like you can set those fields directly for a test run. I haven't found any alternate endpoints that affect those fields.
https://learn.microsoft.com/en-us/rest/api/vsts/test/runs/update?view=vsts-rest-5.0
So, the question is, in a nutshell: How do I update the Failed Tests and Pass Rate fields for a VSTS Test Run using the REST API?
I am programming in C#, using HttpClients to call the REST API endpoints, and passing the relevant data via JSON. Everything is created and updated properly in VSTS; it is just these two fields that don't seem to be working.
I am having this issue. I am creating the run, adding test results then closing the test run. On the front end my runs look like this:
Test run stats
However all my results show passes within the run like this
Test results
Can't understand why this is the case as the graphs on the test runs are correctly picking up the passes and fails.

How to get tasks filter by processDefinitionId in activiti-rest REST API

I am trying to fetch all tasks having specific processDefinitionId. This is my URL:
http://localhost:8080/activiti-rest/service/runtime/tasks?processDefinitionId=reviewSaledLead:1:40
But tasks are not getting filtered by processDefinitionId. Is is giving me all tasks from ACT_RU_TASK table without filtration.
How to resolve this ?
I've looked into it and you are correct: processDefinitionId is not part of that particular REST API, which I think is an oversight.
I've added it in this commit: https://github.com/Activiti/Activiti/commit/86df130a678154f50e241abfec3f3bd99d3f9e7a. It will be part of the next release of Activiti.