Comments (5)
Thx for the fast feedback - Perfect that helps already a lot.
from tcwebhooks.
Hi @Super8film87 You've made some good progress. You might realise that the $build
object in the template is an SBuild
object. There are a few versions of this interface, but for the BuildFinished events (Success, Failed, Fixed, Broken) the $build
will be an SFinishedBuild.
In velocity, calling $build.startDate
will call the getStartDate()
method on the SFinishedBuild
object.
getStateDate()
returns a java.util.Date
, and you can then call getTime()
on it, which returns milliseconds since epoch.
So, I was able to get queue duration like this..
#set($queueDuration = (${build.StartDate.Time} - ${build.QueuedDate.Time}) /1000)
#set($buildDuration = (${build.FinishDate.Time} - ${build.StartDate.Time}) /1000)
{
"queueTime" : "$queueDuration seconds",
"buildTime" : "$buildDuration seconds",
}
which outputs...
{
"queueTime" : "4 seconds",
"buildTime" : "340 seconds",
}
I have not figured out how to get at the Build Steps.
from tcwebhooks.
I've asked the team.
https://youtrack.jetbrains.com/issue/TW-81941/How-to-access-Build-Steps-from-OpenAPI-plugin
from tcwebhooks.
The team at Jetbrains answered the query. Here is a working template that now includes step name and duration.
## Define macro called "getFirstFailedBuild"
#macro( getFirstFailedBuild $myBuild)
#set ($currentBuild = $myBuild)
#set ($previousBuild = $myBuild.getPreviousFinished())
#set ($keepLooping = true)
#foreach($unused in [1..50]) ## only loop 50 times in case there are hundreds of failures
#if ($keepLooping)
#if ($previousBuild) ## Null check
#if ($previousBuild.getStatusDescriptor().isSuccessful())
#set ($keepLooping = false) ## Our $previousBuild is isSuccessful, so the $currentBuild is the last failure
"$currentBuild.buildNumber :: $currentBuild.getStatusDescriptor().isSuccessful()" ## Output something when we find out first failure
#end
#else
#set ($keepLooping = false)
"unknown" ## text to display if getPreviousFinished returns null
#end
#set ($currentBuild = $previousBuild) ## set vars for next iteration
#set ($previousBuild = $previousBuild.getPreviousFinished()) ## set vars for next iteration
#end ## close $keepLooping
#end
#end
#set($queueDuration = (${build.StartDate.Time} - ${build.QueuedDate.Time}) /1000)
#set($buildDuration = (${build.FinishDate.Time} - ${build.StartDate.Time}) /1000)
{
"queueTime" : "$queueDuration seconds",
"buildTime" : "$buildDuration seconds",
"firstFailed" : #getFirstFailedBuild($build)
"steps" :[
#foreach($buildStep in $build.getBuildPromotion().getBuildSettings().getBuildRunners())
#set($stepDuration = ($build.getStatisticValue("buildStageDuration:buildStep" + $buildStep.getId())) /1000)
{
"stepName" : "$buildStep.getName()",
"buildStepDuration" : "$stepDuration seconds"
},
#end
]
}
For me, I get the following when run against a build with steps.
{
"queueTime" : "337 seconds",
"buildTime" : "360 seconds",
"firstFailed" : "908 :: true"
"steps" :[
{
"stepName" : "Build and Package - Maven",
"buildStepDuration" : "244.713000 seconds"
},
{
"stepName" : "SonarQube Runner",
"buildStepDuration" : "110.644000 seconds"
},
]
}
The list of values that can be used to get a statistic are on your build in the REST API.
http://teamcity:8111/app/rest/builds/id:150414/statistics
The id
value is the internal build number. It's in the URL when you view a specific build.
from tcwebhooks.
Cool - will test it. Thx for the support
from tcwebhooks.
Related Issues (20)
- Impossible to save WebHook configuration for non system admin users HOT 5
- Managing Webhooks from Top to Bottom HOT 6
- Investigate Mute or Fix Test callback HOT 6
- TeamCity server cpu and memory spike after enabling tcwebhooks HOT 9
- Calculate Time To Restore HOT 7
- #substringBefore(${buildLog} and alternatives HOT 1
- Muted test webhook doesn't include test name HOT 16
- Webhook that only allows Mute/Unmute events should not allow other events to be selected HOT 4
- build.FinishDate is empty even build is finished HOT 5
- Send all parameters as valid json to elasticsearch HOT 12
- Legacy Webhook Build Failed Template wrong HOT 3
- Cannot format date HOT 10
- Get Information from Performance Monitor (BuildFeature) HOT 4
- Password field is in plan text HOT 3
- REST API returns 500 when editing webhook HOT 7
- Unexpected Error when accessing webhook search results HOT 9
- Cloud Profiles "Events" HOT 4
- Edited Discord template does not send notification. HOT 1
- TeamCity Webhook is removed if you are using versioned settings HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tcwebhooks.