TeamCity API work out how long investigation took to start? - teamcity

Using the TeamCity API:
We are trying to put together a dashboard to work out how long from a build failing, it took for someone to assign themselves to an investigation for the build / project.
We cant find a way to do this as investigations are assigned to projects not builds so there is no way to find out when an investigation started for a particular build ?

If you need to get investigation for build configuration you may use the following REST API:
http://teamcity:8111/app/rest/investigations?locator=buildType:(id:XXXX)
For example, the following request
https://teamcity.jetbrains.com/app/rest/investigations?locator=buildType:(id:Epigenome_GenestackTests)
returns the following response, which has timestamp under assignment node:
<?xml version="1.0" encoding="UTF-8"?>
<investigations count="1" href="/app/rest/investigations?locator=buildType:(id:Epigenome_GenestackTests)">
<investigation id="buildType:(id:Epigenome_GenestackTests)" state="TAKEN" href="/app/rest/investigations/buildType:(id:Epigenome_GenestackTests)">
<assignee username="evgeny.kurbatsky" name="Evgeny.Kurbatsky" id="1107" href="/app/rest/users/id:1107" />
<assignment>
<user username="oleg" name="Oleg Shpynov" id="2" href="/app/rest/users/id:2" />
<timestamp>20160321T122158+0000</timestamp>
</assignment>
<scope>
<buildTypes count="1">
<buildType id="Epigenome_GenestackTests" name="Genestack Tests" paused="true" description="Fast tests" projectName="BioLabs :: Epigenome" projectId="Epigenome" href="/app/rest/buildTypes/id:Epigenome_GenestackTests" webUrl="https://teamcity.jetbrains.com/viewType.html?buildTypeId=Epigenome_GenestackTests" />
</buildTypes>
</scope>
<target anyProblem="true" />
<resolution type="whenFixed" />
</investigation>
</investigations>

Related

Steps are not included in report

I'm creating reports, but steps are not included (look at screenshoot in the end of question!).
I've created ClassLibrary1 project in VS15
I've added NUnit3, NUnitConsole, Specflow and Specflow.NUnit nuget packages.
I've added defaul feature and step definition files.
After that, I ran these commands from cmd(first from nunit folder, second from specflow folder):
nunit3-console.exe --labels=All --out=TestResult.txt "--result=TestResult.xml;format=nunit2" D:\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll
specflow.exe nunitexecutionreport D:\Projects\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj /out:MyResult.html
As I see, steps are not included in output HTML file... I remember that it was working in previous versions, and i saw examples with button like 'expand', which should help to see exact steps been performed in scenario.
What do i miss?
TestResult.txt is
=> ClassLibrary1.SpecFlowFeature1Feature.AddTwoNumbers
Given I have entered 50 into the calculator
-> pending: StepDefinition1.GivenIHaveEnteredSomethingIntoTheCalculator(50)
And I have entered 70 into the calculator
-> skipped because of previous errors
When I press add
-> skipped because of previous errors
Then the result should be 120 on the screen
-> skipped because of previous errors
TestResult.xml is
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="D:\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll" total="1" errors="0" failures="0" not-run="0" inconclusive="1" ignored="0" skipped="0" invalid="0" date="2017-02-28" time="12:37:46">
<environment nunit-version="3.5.0.0" clr-version="4.0.30319.42000" os-version="Microsoft Windows NT 10.0.14393.0" platform="Win32NT" cwd="D:\Projects\ClassLibrary1\packages\NUnit.ConsoleRunner.3.6.0\tools" machine-name="DESKTOP-417JV6U" user="dom" user-domain="DESKTOP-417JV6U" />
<culture-info current-culture="en-US" current-uiculture="en-US" />
<test-suite type="Assembly" name="D:\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll" executed="True" result="Success" success="True" time="0.386" asserts="0">
<properties>
<property name="_PID" value="25444" />
<property name="_APPDOMAIN" value="domain-" />
</properties>
<results>
<test-suite type="TestSuite" name="ClassLibrary1" executed="True" result="Success" success="True" time="0.379" asserts="0">
<results>
<test-suite type="TestFixture" name="SpecFlowFeature1Feature" description="SpecFlowFeature1" executed="True" result="Success" success="True" time="0.378" asserts="0">
<properties>
<property name="Description" value="SpecFlowFeature1" />
</properties>
<results>
<test-case name="ClassLibrary1.SpecFlowFeature1Feature.AddTwoNumbers" description="Add two numbers" executed="True" result="Inconclusive" success="False" time="0.118" asserts="0">
<categories>
<category name="mytag" />
</categories>
<properties>
<property name="Description" value="Add two numbers" />
</properties>
<reason>
<message><![CDATA[One or more step definitions are not implemented yet.
StepDefinition1.GivenIHaveEnteredSomethingIntoTheCalculator(50)]]></message>
</reason>
</test-case>
</results>
</test-suite>
</results>
</test-suite>
</results>
</test-suite>
</test-results>
Output html looks like:
You can generate the step definitions by right-clicking on the feature's text and selecting "Generate Step Definitions"
This will generate the Steps class but it will have only stub methods that throw a NotImplementedException.

TeamCity REST API: Triggering Build with Custom Artifact Dependency

I'm trying to trigger a custom build using the TeamCity 8.1 REST API (see https://confluence.jetbrains.com/display/TCD8/REST+API#RESTAPI-TriggeringaBuild). My builds run fine and I'm able to specify custom branches and properties with no issue. My goal is now to specify a custom artifact dependency for the builds I'm triggering.
The response I receive when creating a build is something like the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<build taskId="1234" buildTypeId="buildConfig1" state="queued" ...>
<buildType id="buildConfig1" name="Build Config Name" ... />
...
<properties count="1">
<property name="testParam" value="Test 123" own="true" />
</properties>
<custom-artifact-dependencies />
</build>
The "custom-artifact-dependencies" tag in this response leads me to believe that there is a way to specify custom dependencies, but I have not found anything in the TeamCity documentation, the TeamCity forums, or from Google explaining how this can be accomplished. Is there something I'm overlooking here or another way of accomplishing this?
Adding the following to as a child of the "build" tag results in an "Artifact dependency should have type 'artifact_dependency'." error:
<custom-artifact-dependencies>
<artifact-dependency buildId="5432" buildTypeId="parentBuildConfig"/>
</custom-artifact-dependencies>
The server may be confusing my intention with the build configuration API for setting and viewing artifact dependencies (e.g. http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/artifact-dependencies/)
I had the same problem
This is what worked for me:
<build>
<triggeringOptions queueAtTop="true"/>
<buildType id="buildConfig1"/>
<custom-artifact-dependencies count="1">
<artifact-dependency id="0" type="artifact_dependency">
<properties>
<property name="pathRules" value="Artifacts_1.zip
Artifacts_2.zip
Artifacts_To_Unzip.zip!/**
"/>
<property name="cleanDestinationDirectory" value="true"/>
<property name="revisionName" value="buildId"/>
<property name="revisionValue" value="5432"/>
</properties>
<source-buildType id="parentBuildConfig" />
</artifact-dependency>
</custom-artifact-dependencies>
</build>
If the 'parentBuildConfig' build is still running, replace the buildId parameter with taskId

Glassfish and Spring Boot: .war re-deployment failed

I am trying to deploy an application build from https://github.com/spring-guides/gs-convert-jar-to-war to local glassfish4. And it delpoys well for the first time (if I can call some exceptions from the framework good behaviour). At least, I can open the project's index page in browser.
But if I try to undeploy it and re-deploy, or just overwrite .war file in autodeploy directory, deployment fails. And nothing seems to be added to glassfish log file.
The projects I published from eclipse using some its mechanisms deployed and re-deployed successfully.
Here is the log with related contents:
http://pastebin.com/zSeMw5tC
What can be the problem?
I did some experiments with Glassfish a while ago. The CDI implementation is really broken IMO (it shouldn't load classes to scan them for annotations), but the apps I tried worked on GF 4 if there is a WEB-INF/classes/META-INF/beans.xml containing
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd"
bean-discovery-mode="none">
<scan>
<exclude name="org.springframework.**" />
<exclude name="org.apache.**" />
<exclude name="com.google.**" />
</scan>
</beans>
Nothing I did ever worked in GF 3 (older CDI spec and no way to exclude things I think).

Is there a way to debug findbugs filters?

I'm using FindBugs and FindBugs Contrib to do some static analysis on my Java code. There are some "bugs" I'd like to filter in my Findbugs report. So I created a findbugs-exclude.xml file and wrote the following:
<?xml version="1.0" encoding="UTF-8" ?>
<FindBugsFilter>
<Match>
<Class name="com.masked.out.for.stack.Overflow" />
<Method name="myMethod" />
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
</Match>
<Match>
<Class name="com.some.other.class.Name" />
<Method name="getSomeProperty" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>
</FindBugsFilter>
My report now excludes the EI_EXPOSE_REP bug, but not the DRE_DECLARED_RUNTIME_EXCEPTION bug. Any hints on how I can debug this? The class name and method names are correct. I copied them right out of the report and pasted them in this file.
The reason I was not getting bugs to show up was due to not having the maven plugin configured correctly. If anyone else is struggling to filter bugs, verify that the excludeFilterFile tag is in the plugin configuration and that it's pointing to a valid file.

Cant get Junit to work with Spring in an ANT build

I am trying to get Spring MVC and Junit working with eachother and I am having trouble configuring the build.xml file. I am fairly new at using ANT and do not really understand all the tutorials. I put the junit.jar file in the lib direcotory, but still am getting the following message from my console.
test:
BUILD FAILED
C:\Java\mmz\WEB-INF\build.xml:63: The <classpath> for <junit> must include junit.jar if not in Ant's own classpath
Total time: 223 milliseconds
Edit
Here is an example of wanting to run just one test
and I am not sure what I need to do, i tried doing something like the following, but I dont quite understand what its doing, so I dont know how to make changes
<path id="classpath.test">
<pathelement location="" />
<pathelement location="${test.dir}" />
</path>
<target name="test">
<junit>
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<test name="TesterTest" />
</junit>
</target>
I am pretty lost on what to do next. Thanks
If you copy-pasted your build.xml file then there is probably a classpath element somewhere. Probably near the top of the file. In that element they have probably listed some paths and/or files. You need to add the junit jar to this section.

Resources