Skip to content

Instantly share code, notes, and snippets.

@gabrielfeo
gabrielfeo / all-cache-artifacts-sorted.main.kts
Last active July 9, 2025 15:49
Get build cache artifacts of a given build scan from a Develocity instance. One script will get only build cache artifacts of Task executions, while the other will get all cache artifacts including of 'artifact transform' operations.
#!/usr/bin/env kotlin
/*
This script demonstrates how to retrieve the cache artifacts that were created for Task and
artifact transform outputs as part of a given build, sorted by size (bytes) descending, using the
Develocity REST API to fetch build information.
(https://docs.gradle.com/develocity/api-manual/)
DISCLAIMER: develocity-api-kotlin is a third-party library, not an official Gradle product.
(https://github.com/gabrielfeo/develocity-api-kotlin)
@gabrielfeo
gabrielfeo / last-publish-by-user-specific-users.main.kts
Last active July 9, 2025 14:19
Get time of last published build scan by user from a Develocity instance. Prefer the "*-specific-users.main.kts" variant if your usernames are known beforehand or are predictable (e.g. derived from the user's work email address), as it'll be much faster.
#!/usr/bin/env kotlin
/*
This script demonstrates how to retrieve the last published build time for each user
provided via stdin, using the Develocity REST API to fetch build information.
(https://docs.gradle.com/develocity/api-manual/)
DISCLAIMER: develocity-api-kotlin is a third-party library, not an official Gradle product.
(https://github.com/gabrielfeo/develocity-api-kotlin)
@gabrielfeo
gabrielfeo / settings.gradle.kts
Created March 21, 2025 18:01
Capture free disk space to a custom value
import java.nio.file.FileSystems
develocity {
buildScan {
background {
FileSystems.getDefault().getFileStores().forEach {
value("Free space: ${it.name()}", "${it.usableSpace}/${it.totalSpace}")
}
}
}
@gabrielfeo
gabrielfeo / captureFingerprints.gradle
Last active March 13, 2025 18:52 — forked from ghale/captureFingerprints.gradle
Capture task classpath fingerprints in a configuration cache–compatible way
def fingerprinter = services.get(org.gradle.internal.fingerprint.classpath.ClasspathFingerprinter)
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { task ->
def objectFactory = task.project.objects
def buildScan = rootProject.buildScan
doFirst {
ClassLoader classLoader = task.getClass().classLoader
while (classLoader instanceof URLClassLoader) {
def fingerprints = [] as Set
def allFiles = [] as Set
classLoader.getURLs().each {
@gabrielfeo
gabrielfeo / pinentry-op.bash
Last active February 20, 2025 17:06
Have gpg fetch key password using 1Password CLI
#!/usr/bin/env bash
# Have gpg fetch key password using 1Password CLI.
#
# 1. Add to ~/.gnupg/gpg-agent.conf:
#
# pinentry-program <path to this file>
#
# 2. Export OP_GPG_PASSWORD_ENTRY_<key-id>=<key-password-reference> variables :
#
@gabrielfeo
gabrielfeo / download-deec-assets.py
Last active January 24, 2025 19:20
A script to download assets from an unintuitive University Of Coimbra file-hosting website.
#!/usr/bin/env python3
'''
Downloads requested assets based on a JSON file that lists a directory tree.
USAGE:
./download-deec-assets.py --json-file deec-assets.json --dir-name '[E2]Eletronica_2'
# or
./download-deec-assets.py --json-file deec-assets.json --dir-id '0fx80'
@gabrielfeo
gabrielfeo / cashapp_gradle_enterprise.gradle
Created January 22, 2025 16:02 — forked from jrodbx/cashapp_gradle_enterprise.gradle
Example Gradle Enterprise config
import groovy.json.JsonSlurper
import static java.nio.charset.Charset.defaultCharset
import static java.util.concurrent.TimeUnit.SECONDS
// Captures build and environment data and stores it in build scans via custom tags, links,
// and values, for one-off and trend analyses.
gradleEnterprise {
buildScan {
@gabrielfeo
gabrielfeo / add-relative-symlinks.py
Last active November 22, 2024 14:15
Adds relative symlinks in the given directory, pointing to the specified files in the current directory. Useful to add symlinks to a nested Gradle build in order to open it separately in an IntelliJ IDE (but prefer making it an included build)
@gabrielfeo
gabrielfeo / randomize-remote-cache-path.init.gradle
Created October 14, 2024 11:45
Randomize Gradle remote cache path for benchmarking upload performance
// Randomizes the cache path so that builds always miss and push cache entries
// to the remote cache. Used to benchmark upload performance when making changes
// to a Develocity instance. Configuration cache must be disabled so that
// a random path is never re-used.
settingsEvaluated { settings ->
settings.with {
// This impl will only work with the Develocity build cache type
assert buildCache.remote.class.name.contains('com.gradle.develocity')
buildCache.remote.path = "cache/${UUID.randomUUID()}"
@gabrielfeo
gabrielfeo / http-bench-tools-sorted.txt
Last active July 11, 2024 14:24
HTTP benchmarking tools from denji/awesome-http-benchmark, sorted by stars
https://github.com/wg/wrk
https://github.com/loadimpact/k6
https://github.com/tsenart/vegeta
https://github.com/rakyll/hey
https://github.com/ddosify/ddosify
https://github.com/mcollina/autocannon
https://github.com/codesenberg/bombardier
https://github.com/hatoo/oha
https://github.com/giltene/wrk2
https://github.com/six-ddc/plow