Comments (7)
I'm guessing you want to find the first build failure for the current build assuming it is failed and not broken (since that would imply the previous build was successful).
I'm not at the computer, but I'll have a think about it. If the previous SFinishedBuild is available in the payload (I don't think it is) you could access that time, but there is no guarantee that that was the first failure.
I imagine a helper tool (like the one you found for dates) that gave access to the build history some how would be a useful feature. I'll take some time to look at it over the weekend.
from tcwebhooks.
I'm guessing you want to find the first build failure for the current build assuming it is failed and not broken (since that would imply the previous build was successful).
So in the template we can use "buildResultDelta" which use "broken", "fixed" & "unchanged". But I do not find where is data is coming from. So a broken build is the first failure after a successful build (state change). So I'm really interested into the state change.
I didnt found any entry so thats the reason why I asked :D Thx for your support
from tcwebhooks.
Yeah. That value is calculated against the previous build, and only the result is available.
And even if it was available, it would refer to the previous build, which might not have been the first time the build failed. I'm presuming you want to know the total time from first failure to resolution.
from tcwebhooks.
ah ok - got it. so we would need a attribute with the date. Ok sounds like this would be not possible :D
from tcwebhooks.
I just need to write a velocity tool that exposes a method to fetch the first failed build.
That's fairly simple to do. Which version of tcWebHooks are you using? 1.2 or 2.0?
from tcwebhooks.
I've figured out how to accomplish something similar to what I think you want from velocity. No code change required in the plugin.
I have defined a macro named getFirstFailedBuild
. If finds the first failed build and assumes the current build is failed.
You probably want this to run on "fixed", so you might want to call it with $build.getPreviousFinished()
.
It simply gets the previous build from the current build and saves it as a variable.
Then loops around getting the next previous build each time until it find a successful one.
If our previous build was successful, then our current build in the loop must be the last failed one.
## 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 isSuccessful, so the $currentBuild is the first failure
"$currentBuild.buildNumber :: $currentBuild.getStatusDescriptor().isSuccessful()" ## Output something when we find our 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)
}
This is what I get. My build 305 was a broken build. Builds 302 to 305 all failed, so the first failed build was 302
Note: The javadoc for getPreviousFinished
says:
returns previous finished build (ordered by changes). If this build is personal, this method can return previous personal build, otherwise only regular builds are returned.
From my testing, it appears to only return builds on the same branch.
from tcwebhooks.
I'll close this. Feel free to message back if you need further help.
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 Queue and single Build Step Duration HOT 5
- #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.