Last active
August 28, 2025 17:40
-
-
Save gabrielfeo/f7bfa6fcfb2d0b663517b13a9014867c to your computer and use it in GitHub Desktop.
Get the accumulated duration of specific tasks from a Develocity Build Scan, using its REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env kotlin | |
@file:DependsOn("com.gabrielfeo:develocity-api-kotlin:2024.3.0") | |
import com.gabrielfeo.develocity.api.* | |
import kotlinx.coroutines.runBlocking | |
val buildScanId = requireNotNull(args.getOrNull(0)) { "Expected arg 0: build scan ID" } | |
val taskPaths = System.`in`.bufferedReader().lineSequence() | |
.map { it.trim() } | |
.filterTo(LinkedHashSet()) { it.isNotEmpty() } | |
.also { | |
require(it.isNotEmpty()) { "Expected task paths in stdin" } | |
} | |
val api = DevelocityApi.newInstance() | |
val perf = runBlocking { | |
api.buildsApi.getGradleBuildCachePerformance(id = buildScanId) | |
} | |
val tasks = perf.taskExecution.asSequence().filter { it.taskPath in taskPaths } | |
val totalExecution = tasks.sumOf { it.duration } | |
println("Tasks' total duration (serial): $totalExecution ms") | |
val totalTaskActionExecution = tasks.sumOf { it.duration - (it.fingerprintingDuration ?: 0) } | |
println("Tasks' total 'task action' execution duration (serial): $totalTaskActionExecution ms") | |
api.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment