Azure devops pipeline testrun results to be updated in testrail - azure

Hi we run the azure devops pipeline having all the test cases. We are using jmeter scripts to run and producing the run results for all the test cases. Is there any possibility that we could update these test results in TESTRAIL automatically after every run? Testrail is where we store our test cases.

TestRail has an API so you should be able to submit results from JMeter directly, take a look at the Example POST Request
POST /index.php?/api/v2/add_result/1 HTTP/1.1
Host: example.testrail.com
Content-Type: application/json
{ "status_id": 1 }
The equivalent JMeter's HTTP Request sampler setup would be something like:
you will also need to add a HTTP Header Manager and configure it to send the relevant Content-Type header

Related

Return Hosted Agent usage via API?

I want to create some reporting around pipelines that use MS hosted public agents to run jobs.
This info is available via the UI (Org Settings > Agent Pools > Azure Pipelines) - but not via the REST API it would seem.
I can return all Agent Pools:
GET https://dev.azure.com/{organization}/_apis/distributedtask/pools?api-version=7.1-preview.1
...and then filter on the "isHosted" property - but the pool info has no run history.
Alternatively I can loop through all projects in the Org (lots!), loop through all pipelines, then finally loop through all runs for each pipeline - but the run doesn't have an agent property either.
I tried looking at Service Hooks to trigger a webhook when a build is run to see if I could pull the agent / pool detail from the payload - buts its not in there either.
Any other ideas welcome.
When encountered those situation, you always have two ways.
1, First of all, if UI can show what you want, you can handle the data via python crawler.
#python crawler get the content of the page
import requests
url = "https://dev.azure.com/<Organization Name>/_settings/agentpools?poolId=9&view=jobs"
payload={}
headers = {
'Authorization': 'Basic <Personal Access Token>',
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
#save the content to a file
with open('jobs.html', 'w', encoding='utf-8') as f:
f.write(response.text)
After saving the data, use the regular expression to filter the data you want.
(This method is just a suggestion for common handling.)
2, Or you can use this REST API to query the public agents run history of your current situation:
https://dev.azure.com/<Organization Name>/_apis/distributedtask/pools/<Pool ID>/jobrequests
Public or private can be distinguished by ParallelismTag:

How to submit "form-data" in ADF "Web" activity POST call

I am trying to move data from a RESTFul API running on my on-prem application to ADB with ADF. I have installed self-paced IR in my private network to run the activity/pipeline. Now in one of my
API requires form-data to submit in POST call. Equivalent Postman looks like below
How to perform the same in ADF (As I will be running in self-paced IR dataflow is not applicable)? I am trying with "Web" Activity but dont know how to pass form data in it.
You are unable to pass form data in your ADF's Web Activity as you have selected incorrect method in Web activity:
You can select POST method from the dropdown as such:
After this you will get a place to add request body.
Also to get same effect of selecting form-data in postman, you can set 2 cookies as:
Content-Length: length of your request body in bytes
Content-Type: multipart/form-data; boundary= some value as boundary
Content-Type header reference

POST body for Google Cloud Build - Webhook Triggers

The Google Cloud Build - Webhook Trigger create trigger documentation shows the proper URL to POST to invoke the build trigger. However the documentation does not describe the POST body, which seems to be required. I have successfully triggered the cloud build webhooks using content-type: application/json header with a POST body of {}, but it would be nice to know:
What is the POST body supposed to be?
Are we able to pass substitution variables in the POST body?
The Google Cloud Build - REST API documentation provides some additional hints that a HttpBody payload is accepted, but no additional information past that as for as I can tell.
The body is what you want! In fact, in your trigger you customize your substitution variable like this (from the documentation)
--subtitutions=\
_SUB_ONE='$(body.message.test)', _SUB_TWO='$(body.message.output)'
So, your body need to be like that
{
"message": {
"test": "test value",
"ourput": "my output"
}
}
The data are automatically extracted from your body content. So you can add more substitutions or change the format of your JSON and thus of your substitutions value.

Azure Build Pipeline - Pause and Enable DefinitionQueueStatus change REST API

We have many dozens of build pipelines and we want to pause and resume (re-enable) build pipelines from a simple webapp interface as we are making config changes frequently. Here is the MS doc explaining this API:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/update%20build?view=azure-devops-rest-5.0#definitionqueuestatus
From this documentation, it appears I need to hit the REST API and change/toggle the DefinitionQueueStatus -- however, this documentation only shows a sample for a build specific operation, whereas I want to pause then re-enable the entire build pipeline. What is the proper way to make this call?
I'm using fetch - and I've tried many dozen formats in the call - the 'ourorg' and 'ourproject' are correct (we use this call structure for many other calls), but all fails for this call below. I grabbed the 'definitionID' from the URL I can visibly see when in the Azure devops portal on the specific build pipeline page, and I'm using it for the {buildID} as I don't know what else to put there. Any guidance to help here is appreciated - I don't need to use fetch btw - any working sample will help here:
fetch(https://dev.azure.com/our_org/our_projectname/_apis/build/builds/definitionId=1593?retry=true&api-version=5.0 {
method: 'PATCH ',
credentials: 'same-origin',
body: 'DefinitionQueueStatus: "Enabled"'
}).then(function(response) {
console.log(response);
})
It seems that the body is incorrect in your post. Here is sample about how to use POSTMAN to access Azure DevOps Services REST APIs.
Generate the PAT, and then record the token, it is important to use to authorization, please see this document.
Create a new request in POSTMAN, it is recommended to put the request in a collection for Azure DevOps Services REST API;
Select the authorization as Basic Auth, you can input the username as any value, and the password as the token which is generated in step1.
Basic Auth
Set the REST API which you want to use,and select the request method type(GET,POST,FETCH ....), here you use https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.0.
In the Body tab, you can set the request body as raw in json format, and input the value as following:
{
"buildNumber":"#20190607.2",
"buildNumberRevision":1,
"definition":
{
"id":1,
"createdDate":null,
"queueStatus":"paused"
}
}
Everthing is ready now, you can send the request, if sccuess, you will get the response from the REST API.
In your post, the body content is incorrect, the Request Body should meet the format in the REST API document. The DefinitionQueueStatus is a type in definitions. In addition, if you send the request with parameter retry, you will get the message The request body must be empty when the retry parameter is specified..

Is it possible to use msmdpump approach when connecting to azure analysis service

For on-prem analysis services (reference https://learn.microsoft.com/en-us/sql/analysis-services/instances/configure-http-access-to-analysis-services-on-iis-8-0) it is possible to configure http endpoint (which you can use for implementing custom authentication). Is there a way to expose http endpoint also for azure version of analysis services ?
I tried playing with msmdpump.ini and all I got was various errors.
UPDATE
Looking at reflected Microsoft.AnalysisServices.AdomdClient.dll - the azure endpoint actually IS http endpoint. The communication goes like:
POST https://[yourregion].asazure.windows.net/webapi/clusterResolve
{"serverName":"your_as_server_name"}
Reply:
{"clusterFQDN":"[prefix]-[yourregion].asazure.windows.net",
"coreServerName":"your_as_server_name",
"tenantId":"... tenantID"}
And then
POST https://[prefix]-[yourregion].asazure.windows.net/webapi/xmla
Authorization: Bearer your_azure_ad_jwt_here
x-ms-xmlaserver: your_as_server_name
// xmla request inside the body
So in theory one should be able to leverage that to create a http proxy. However neither of those is documented/officially suported.
I tried this and made it work for case of Execute (you can use Execute + Statement for most tasks)
With second request you need three more headers (not sure about User-Agent):
User-Agent: XmlaClient
SOAPAction: urn:schemas-microsoft-com:xml-analysis:Execute
x-ms-xmlacaps-negotiation-flags: 1,0,0,0,0

Resources