How do I get the testCaseResultId for a Azure DevOps API call - azure-devops-rest-api

I have a postman collection setup with all of the Azure DevOps API calls for "Tests". I notice that a lot of the API calls you need the "testCaseResultId" in the endpoint. I don't know how to get this id. I've looked at all of the responses and I don't see where it returns this. Could someone please help!? I have 11 calls that need this.
Ex. GET https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/Results/{**testCaseResultId**}/Iterations/{iterationId}/actionresults/{actionPath}?api-version=5.0

To get the value of a testCaseResultId, you can try with the following ways:
Use the REST API "Results - List" to list all the test results for a test run. From response body, you can see the testCaseResultId of each test results in the specified test run.
View the testCaseResultId from the web page of Azure DevOps. In the project where the test run is in, navigate to 'Test Plans' > 'Runs'. Find the test run and click to open it. Select 'Test results' tab, you can see the results of all the test cases executed in this run. Click one test case result to open it. On the address bar of the web browser, you can see the complete URL of this test case result. In the URL, you can see the testCaseResultId is contained.

Related

Updating JIRA issues from gitlab pipeline

I want to move an issue to the deployed stage (transition) when the gitlab pipeline of a merge request has finished. Is that even possible?
My Idea so far:
The pipeline is related to that specific issue by both the branch name (see 1.) of the merge request and also the message of that merge request like so "Finish PV-1234".
I can parse the issue key from the branch name.
I can call a server to run a script making the Jira api call.
If you directly want to close the issu, look into the gitlab jira integration docs - therefore you have to add a description to your MR, to tell the integration to close the issue, as soon as the MR was merged.
If you want more control, write yourself a simple script, that first gets the ids of the available transition (You can get them via /rest/api/3/issue/{issueIdOrKey}/transitions see here) and after that posts the transition you want (You can do that by posting on the same endpoint, as the get command mentioned before see here).
Sad that the jira integration doesn't provide more issue-movement than jsut closing issues...

Trigger Jenkins job via Slack command - 403_client_error

I'm trying to do a pretty simple thing I believe - trigger a Jenkins job from a slash command in slack. I want to type /dump in slack and that should trigger particular jenkins job. I'm using Slack Slash command to achieve this and the setup is very simple - type command, type URL, select POST/GET method.
I tried two methods - first was to use Build Authorization Token Root Plugin following this tutorial - in this case I configured Slack slash command to make GET request on the URL: http://jenkins_url:8080/job/db-dump-setup/build?token=MY_TOKEN - If I put the URL to my browser, the job gets triggered, if I run the /dump command, slack responds with:
slackbot [3:41 PM]
Darn - that slash command didn't work (error message: `403_client_error`). Manage the command at text.
The second approach I tried was following this tutorial. In this case I created new user in Jenkins and got API token. When running this command from my terminal: curl -X POST http://USER:TOKEN#slack_url:8080/job/db-dump-setup/build, the job gets again triggered, however when configuring the Slack slash command with the same URL and making POST request, I get the same error: 403_client_error
I tried to google this specific error but didn't find anything useful, also there are no more details for the error or any logs which could help me to troubleshoot this further.
Anyone run into something similar and knows how could I get this resolved?
I was able to resolve this so answering my own question in a case someone else runs into this. In order to make the first case work (Using the GET request), I had to enable the "Allow anonymous read access" in Jenkins, in Manage Jenkins -> Configure Global Security as per the screenshot below.
You should not need to enable anonymous access.Your jenkins requires authentication. Update your url like http://user:auth-token#jenkins-host:port.Auth token can be generated at the following URL JENKINS_HOST/me/configure

Automated Test Results - JUnit -> How to do ordinary grouping/formatting?

I am new around here, I have done a lot of googling, searching on this site and asking around and have not found a satisfactory answer.
I develop automated tests, UI as well as API. These are then run by TFS and the results are put into a JUnit xml document, which is then read by TFS. But alas the formatting is atrocious and leaves one unable to use the output for anything.
Vis:
There is no information about the Test Suite (which is there in the XML), the actual request sent (which is in the log) or response received and so one is left with absolutely no context to understand what has actually taken place (which request was sent, what test group/suite it belongs to and what any potential error was).
As far as I have been able to uncover, TFS simply has little to no support of proper test result formatting when it comes to automated testing. I am very surprised by this in 2018. Not even any documentation that allows me to develop my report structure/format in some kind of script.
What alternatives do I have? Can I automatically attach a generated HTML report somehow in TFS? Can I output more info anywhere?
You can group by Test Suite, Owner, Priority etc...
And you can double click the specific test result and navigate to the test run Summary to see more information there, also you can attach files there.
More information please see Review continuous test results after a build

Jenkins API - buildWithParameters and fileParameter

so we're trying to use the Jenkins API to invoke a build with a file parameter. Basically we're trying to give it the files to build in ZIP format. We have a ZIP plugin installed to unzip the build file, but we can't get that far.
Basically we're trying to use the buildWithParameters endpoint, but based on scouring info available online combined with a test I have set up in Postman, it would seem that buildWithParameters only works with parameters that exist on the query string.
If we use the build endpoint, we're able to submit the file successfully, both in a node app we built (using the request library) and in Postman. But if we roll back to buildWithParameters, using the same exact configuration, the file is not processed successfully by Jenkins (we get a file not found error).
Am I right about buildWithParameters only working with query string parameters?
To preempt why not just use the build endpoint: we need the build number back, which we get back from buildWithParameters but don't seem to get back with build.
To reiterate my question: is it possible to use the buildWithParameters endpoint and upload a file parameter? It would seem like it is, but we have not been able to get it to work.

TFS New Build and Build Process Template (XAML): How to pass/get unique build request ID

I am calling a console application from within a TFS build process template (copied of DefaultTemplate.xaml). I would like to pass a the unique "Request ID" to the app. I cannot find an argument or parameter in the XAML with this value. Nor can I find much documentation on the "Request ID", however I know one must exist based on the Build history. The build history "View Summary" tab shows a request ID (ex: "Request 12345").
How can I get this value within the template (xaml)
Edit: In the TFS Database (tfs_defaultcollection), I believe this is tbl_Build.BuildID
Its a string but it looks like BuildNumberFormat is available via the build process. I also see BuildDetail.BuildNumber.
I was able to get the TFS Request ID through a collection on the BuildDetail object: BuildDetail.RequestIds.Item(0). This is a collection so I need to verify it has values and that Item(0) is not null.
I am not certain why RequestIds is a collection? I assume theoretically you can have more requests associated with a build? Not necessarily clear, but certainly consistent with the TFS build process.

Resources