Ability to expose test statistics for non-maven build steps in TeamCity - teamcity

Normally (when used with Maven), in order to get the number of failed/passed test we can check TestOccurrences element in Teamcity REST API.
What would be the way to report and fetch test stats for non-maven steps (e.g. custom shell script)?
Is it possible to manually set TestOccurrences somehow, so all step types would report stats in the similar way? If not, how can we make custom stats available with Teamcity REST API?

Related

Rest api to get sonarqube info from bamboo build or vice versa

Is there any way I can get any sonarqube api which can provide the build number of bamboo or any bamboo api which can give sonarqube info.This would really help.
I have so far tried both side but i am surprised both the system are quite clueless about each other. Why it is not possible that a build which ran sonarqube as as one of it's job doesn't have any information about that. Also neither in sonar it tell which build has actually triggered that sonar execution
(Not sure I understand what exactly you are looking for, perhaps this ...? )
I don't believe you can relate a specific Activity (SonarQube analysis) to a specific build (Bamboo), just project to job.
You must have SonarQube Server configured in Bamboo
When executing your job, you can add these sonar.links optional parameters to the analysis step:
sonar.links.homepage Project home page.
sonar.links.ci Continuous integration.
and
sonar.links.scm Project source repository.
sonar.links.issue Issue tracker.
Maybe also specify sonar.host.url=$SONAR_HOST_URL (where SONAR_HOST_URL is the global setting in Bamboo) in the analysis step parameters.
Those populate the Project Overview page sidebar:
That should provide the links from SonarQube back to the other systems of interest.
If you have properly configured Bamboo, you should see a link in Bamboo to the SonarQube project, post execution.

create custom build definition in VSTS using script

I am creating CI/CD pipelines in VSTS using GIT repository.
I need to use the same steps from UI while creating build definition and release configuration for projects so i want to get off this repeating manual steps and create some automation around it so I don't have to do the same steps every time.
Can anyone tell me how it is possible using scripts or any other things?
To create build definitions you have two options:
Use the new YAML builds, which allows you to specify the whole build in a YAML file instead of UI elements.
Use the Build Definition REST API create the definition locally in json form and submit it to VSTS in a single transaction. There is a nice PowerShell library called "VSTeam" which wraps the REST API functions in powershell cmd-lets.
Another thing to look at would be the use of Task Groups, these allow you to abstract away a sequence of tasks and turn those into a single reusable task.

TeamCity/Sonar: Fail build if some metric increases

We're using TeamCity with the Sonar plugin. Is there a way to fail the TeamCity build if some metric (i.e. number of Blocker issues, amount of technical debt, etc.) increases within Sonar, or if it just fails the Quality Gate? I haven't found any documentation regarding this.
For now, the options available for this are
the Build Breaker Plugin (assuming Team City is compatible with the way this plugin woks)
adding a script step in your job (again, assuming TC supports it) to poll SQ in a loop for the completion of analysis report processing, then to grab the QG status and conditionally fail the build.
2018 EDIT
There is now non-blocking support for this within Jenkins Pipelines. More in the docs.
yes you can do it using powershell scripts .Call the sonar rest api for the project using metric and metric key .Compare the result with the project if the metric value dose not match the exit from the build.

Get parameters from multiple build to one snapshot dependent build [teamcity]

In Teamcity 9.0.1 I have several builds, which ends up on similar steps, but with different parameters.
In fact, those are servicing steps, not needed by a build to conclude, that build is ok, but they are needed for service, so, currently, they are just running and consuming time.
What I am trying to reach - is move those steps to completely separate build, and invoke it on successful build end trigger. However, I could not figure out - how to pass changes parameters to these newly created build?
Snapshot dependency does not give me level of control I would like to have, as it requires me to define dependency parameters from specific build id, instead of reading them from build, which just ends.
Using artifact dependency by downloading .teamcity/properties/build.finish.gz!** fails with error:
Unknown archive type
and, actually, will oblige me to create additional xml parser
There's nothing built in to trigger builds with custom parameters on a finish-build trigger.
You will have to use the TeamCity REST API / HTTP endpoint to trigger the servicing build with custom parameters - you can pass them as key/value pairs using the following syntax (preferably use HTTPS of course):
http://testuser:testpassword#teamcity.jetbrains.com:8111/httpAuth/action.html?add2Queue=MyBuildConf&name=<full property name1>&value=<value1>&name=<full property name2>&value=<value2>
For further information see the docs.
Implementation-wise you should be able to do what you want in a few lines of powershell as a last step in the triggering build configs - they would have to pass the build parameters you want. If you use this in multiple build configurations I'd move this step into a common template or use a meta-runner.

Per-test sample data generation for load testing?

I have a set of load tests, each testing a specific section of Sharepoint site. How can I automate the generation of sample data prior to each test?
I know that load tests allow me to specify tests that are run before/after a specific virtual user's test mix, but those are meant for user-specific setup like logging on. I want to create sample data for all users.
I can put my setup code into the Team Build template, but that doesn't take into account whether the test using the sample data is in the test list being run or not. If I modify the test list, I would also need to modify the build template as well. I cannot put the setup code into a test that is run before the load test either, because load tests must be run with the .Net 4.0 framework while accessing Sharepoint's API requires 3.5.
I could rewrite my sample data generation logic with Powershell and start it from a .Net 4.0 unit test. Is it my best option or is there a more elegant way?
I think you question is more TeamBuild related than SharePoint. For short, the best way how to setup (and teardown) testdata in SharePoint is using PoSh in conjunction with the Microsoft.PowerShell.SharePoint SnapIn.
You can start your PowerShell scripts from Everywhere in TeamBuild. That's actually how I extend the default TeamBuild template. I've create a single custom build template, this template contains numerous PoSh hooks. While setting up a new project you can easily hook your scripts everywhere you need.
To be really independent from any .NET FX version you could create your sampledata using REST DataServices (ListData.svc)

Resources