How to List all test names in teamcity using REST API - teamcity-8.0

I am trying to get List of tests as defined here.https://confluence.jetbrains.com/display/TCD8/REST+API#RESTAPI-Tests
But I can't get the list of test names from myteamcity/app/rest/testOccurrences?locator=buildType:(id:1140)]
Is there another way to get those List of passed/failed tests?

I know that long time has past since this question, but I accidentally stumbled upon it so here is the answer if someone else has a similar problem.
If I understood the Teamcity documentation correctly you can't use buildType with Tests. Supported locator is actually id of the exact build:
Rest API Tests
But what you can do is get the list of builds for a buildType:
http://myTeamCity:100/guestAuth/app/rest/buildTypes/id:AXPL_TestDaily/builds/
And then use one of these build ids to get the tests:
http://myTeamCity:100/guestAuth/app/rest/testOccurrences?locator=build:(id:109)
Considering that you wrote integer as an id in your example, maybe you just already have the correct id, but you have resource path wrong as it is not id for buildType, but for build, because buildTypes have strings for ids.

Related

Pubmed API returns less results than web interface

I'm trying to access Pubmed results via R using their API, but I consistently get fewer results than what the same query achieves when used with the web interface. By digging in the output I noticed that the problem lays in a different query translation between the two access methods.
I am using the rentrez package, but the results I get are the same also with other related rpackages, so I guess it's related to the API itself.
here's the code to reproduce the results:
install.packages('rentrez')
rentrez::entrez_search(db="pubmed", term = '((model OR models OR modeling OR network OR networks) AND (dissemination OR transmission OR spread OR diffusion) AND (nosocomial OR hospital OR "long-term-care" OR "long term care" OR "longterm care" OR "long-term care" OR "hospital acquired" OR "healtcare associated") AND (infection OR resistance OR resistant)) AND (2010[PDAT]:2020[PDAT])')$count
[1] 7157
The same query on https://pubmed.ncbi.nlm.nih.gov/ returns 9263 results.
Not sure if you still need this now. Just in case someone else has the same problem.
I had the same issue as you did and I found something might be useful from a GitHub issue.
It seems that the API service needs to be updated to match the new web service, but it's been a year now and still no promising announcement has been made by the official.
An alternative is provided by the easyPubMed author. Hope this is what you were looking for.
easyPubMed Issue

Is there a way to find the workitems for a release in Azure DevOps Api 5.1?

I can find a release in Azure DevOps Api 5.1 by a request to https://vsrm.dev.azure.com/mycompany/myproject/_apis/release/releases/myreleaseid?api-version=5.1
How can I get the workitems of that release as shown on the devops portal under Deployment - Stages - Workitems?
My naive approach just using https://vsrm.dev.azure.com/mycompany/myproject/_apis/release/releases/myreleaseid/workitems?api-version=5.1
resulted in a 404.
There is a stakeholder in the workitem and I want to send him a notification adter the release.
How can I get the workitems of that release as shown on the devops
portal under Deployment - Stages - Workitems?
Hard to say, but I don't find any document about this topic... So I determine to use F12 to find that. And here's the one I finally find:
Get:https://vsrm.dev.azure.com/mycompany/myproject/_apis/Release/releases/myreleaseId/workitems?baseReleaseId={my baseReleaseId}&%24top=250&artifactAlias={my artifactAlias}
It will returns the IDs of the workItems for the release. Its response format:
After you get the IDs, it's easy to get details if you need using Get Work Items Batch or what.
In addition:
1.myreleaseId is the ReleaseID. (On my side, the ID is 7 if it's Release-7)
2.my artifactAlias is this:
3.For my baseReleaseId, I'm not 100% sure about its meaning. I think it could be something like ReleaseToCompareAgainst. Hint from Daniel. (On my side, if my releaseId=7, then I use basereleaseID=6(7-1), it works to get the correct WIT ids). (Actually I suggest you can use F12 in that web page to check your corresponding URL.)
And according to Mathias F: The baseReleaseId realy is the last previous release that has a deployment (-1 in some cases)
4.About how to use F12 to find rest api which may not be documented:
Hope all above helps :)

How to restrict fields returned by stackexchange api, and turn off paging?

I'd like to have a list of just the current titles for all questions in one of the smaller (less than 10,000 questions) stackexchange site. I tried the interactive utility here: https://api.stackexchange.com/docs/questions and it both reports the result as a json at the bottom, and produces the requesting url at the top. For example:
https://api.stackexchange.com/2.2/questions?order=desc&sort=activity&tagged=apples&site=cooking
returns this JSON in my browser:
{"items":[{"tags":["apples","crumble"],"owner":{ ...
...
...],"has_more":true,"quota_max":300,"quota_remaining":252}
What is quota? It was 10,000 on one search on one site, but suddenly it's only 300 here.
I won't be doing this very often, what I'd like is the quickest way to edit that (or similar of course) url so I can get a list of all of the titles on a small site. I don't understand how to use paging, and I don't need any of the other fields. I don't care if I get them, but I'm thinking if I exclude them I can have more at once.
If I need to script it, python (2.7) is my preferred (only) language.
quota_max is the number of requests your application is allowed per day. 300 is the default for an unregistered application. This used to be mentioned directly on the page describing throttles, but seems to have been removed. Here is historical information describing the default.
To increase this to 10,000, you need to register an application and then authenticate by passing an access token in your script.
To get all titles on a site, you can use a Python library to help:
StackAPI. The answer below will use this library. DISCLAIMER: I wrote this library
Py-StackExchange
SEAPI
StackPy
Assuming you have registered your application and authenticated we can proceed.
First, install StackAPI (documentation):
pip install stackapi
This code will then grab the 10,000 most recent questions (max_pages * page_size) for the site hardwarerecs. Each page costs you one API hit, so the more items per page, the few API calls.
from stackapi import StackAPI
SITE = StackAPI('hardwarerecs')
SITE.page_size = 100
SITE.max_pages = 100
# Filter to only get question title and link
filter = '!BHMIbze0EQ*ved8LyoO6rNjkuLgHPR'
questions = SITE.fetch('questions', filter=filter)
In the questions variable is a dictionary that looks very similar to the API output, except that the library did all the paging for you. Your data is in questions['data'] and, in this case, contains a list of dictionaries that look like this:
[
...
{u'link': u'http://hardwarerecs.stackexchange.com/questions/29/sound-board-to-replace-a-gl2200-in-a-house-of-worship-foh-setting',
u'title': u'Sound board to replace a GL2200 in a house-of-worship FOH setting?'},
{ u'link': u'http://hardwarerecs.stackexchange.com/questions/31/passive-gps-tracker-logger',
u'title': u'Passive GPS tracker/logger'}
...
]
This result set is limited to only the title and the link because of the filter we applied. You can find the appropriate filter by adjusting what fields you want in the web UI and copying the filter field.
The hardwarerecs parameter that is passed when creating the SITE parameter is the first part of the site's domain URL. Alternatively, you can find it by looking at the api_site_parameter for your site when looking at the /sites end point.

java-how to get number class files executed by particuler test class from sonar qube data base

hi guys how can i get information like how many number of class files which will be executed from particular test class from sonarqube database,my sonarqube database is resided in MySQL db i am not finding any answers can guys help to this problem
The short answer is: it is not recommended to access SonarQube DB to get information, so forget about directly manipulating SQ's database.
A longer answer might be: have a look at SonarQube's webservice API, especially these ones :
http://nemo.sonarqube.org/api_documentation/api/tests/list
http://nemo.sonarqube.org/api_documentation/api/tests/covered_files
The first one should allow you to retrieve all test id then you can pass the ID you're looking for to the second webservice then check the size of the files array... but I don't think that this will be easy as it isn't straightforward to get the testFileId you need to feed the first webservice (you can't pass a file's key as far as I know.)

Jenkins and JUnit

I've read over the Jenkins site and its JUnit plugin, and for some reason something that is very basic is just not apparent to me.
Jenkins has an Email-ext plugin for sending custom/advanced notification emails whenever a build is ran. In these emails you can place "content tokens" that are runtime variables that get replaced with dynamic values when the email is being generated.
One of these tokens is TEST_COUNTS which allows you to display the number of JUnit tests that ran, or which failed, etc.
How does one go about getting Jenkins to display this information correctly? Is there a plugin I need, and if so, which one? I have my build running JUnit and generating an XML report. I assume Jenkins somehow parses JUnit results out of that XML and uses it to give values to that token.
But on the other hand, I've read "literature" (mailing list posts) that seems to suggest that in order to use that token you need to use Jenkins to run the unit tests, not a junit Ant task from inside your build script.
Can someone clarify this for me and perhaps even set out the "order of operations" for what steps I need to take in order to be able to make use of this token?
It would be supremely useful to get test counts in our build notifications.
Your first explanation is right. You tell Jenkins where to search for JUnit output files, and it parses them to find out the test results:
The test results appear on each project and build page, so as long as you're seeing the correct results there, you should get the correct token replacements in your e-mails
Add something like this to the content in the "Editable Email Notification" configuration:
Total = $TEST_COUNTS
Failed = ${TEST_COUNTS,var="fail"}
I also recommend the Jenkins users mailing list for Jenkins questions, usually helpful.