Extract statistics to print as TeamCity build status

757 views
Skip to first unread message

Yuri Zelikov

unread,
May 29, 2014, 9:37:28 AM5/29/14
to gat...@googlegroups.com
Hi
I am running a gatling simulation from TeamCity and I want to print the final test results in the TeamCity status. To do this I have to access the results at the end of the test and print it to console in a certain way .i.e 
log.info(s"##teamcity[buildStatus text='max: ${global.responseTime.max}} | min: ${global.responseTime.min} | mean: ${global.responseTime.mean}")}
Is there any way to do this?
Thanks

Excilys

unread,
May 29, 2014, 11:07:38 AM5/29/14
to gat...@googlegroups.com
I'm not familiar with Teamcity, sorry. You can maybe use the same JSON file used by the Jenkins plugin. Check out result directory content.
--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yuri Zelikov

unread,
Jun 1, 2014, 4:59:30 AM6/1/14
to gat...@googlegroups.com
Thanks, yeah parsing json is easier than stats.tsv, so I can try to parse it with groovy script and update TeamCity status. Is there any way to know what is the folder name for specific run? For some reason every time I run the simulation it updates all other folders so I can't check what is the most recent one.

Excilys

unread,
Jun 1, 2014, 5:32:29 AM6/1/14
to gat...@googlegroups.com
You can either parse the last line displayed in the console or force it with a command line option. See Configuration wiki page.

Yuri Zelikov

unread,
Jun 1, 2014, 7:36:17 AM6/1/14
to gat...@googlegroups.com
I ended up with the following groovy script:

@Grab(group='com.googlecode.json-simple', module='json-simple', version='1.1.1')
import org.json.simple.JSONValue

def folder = new File('target/gatling/results').listFiles().sort() {
    a,b -> a.lastModified().compareTo b.lastModified()
}
def folderPath =  folder[0].getAbsolutePath()
println "path to results: ${folderPath[0]}"
def stats = JSONValue.parse(new File("$folderPath/js/global_stats.json").text)

println "##teamcity[buildStatus text='requests# ${stats.numberOfRequests.total}| failed:${stats.numberOfRequests.ko}| max:${stats.maxResponseTime.total}| min:${stats.minResponseTime.total}| mean:${stats.meanResponseTime.total}| 95%:${stats.percentiles1.total}| 99%:${stats.percentiles2.total}']"

Stéphane Landelle

unread,
Jun 2, 2014, 6:19:42 AM6/2/14
to gat...@googlegroups.com
Nice!

Litr Piva

unread,
Aug 26, 2016, 8:58:23 AM8/26/16
to Gatling User Group
Yuri, can you please provide steps how to use this groovy script for guys who new to TeamCity?

воскресенье, 1 июня 2014 г., 14:36:17 UTC+3 пользователь Yuri Zelikov написал:
Reply all
Reply to author
Forward
0 new messages