Skip to content

Instantly share code, notes, and snippets.

View jprinet's full-sized avatar

Jérôme Prinet jprinet

  • Bayonne, France
  • 01:22 (UTC +02:00)
View GitHub Profile
import com.gradle.scan.plugin.BuildScanExtension
import org.gradle.util.internal.VersionNumber
import java.nio.charset.StandardCharsets
import java.util.Collections
import java.util.Optional
import java.util.jar.JarFile
import java.util.stream.Stream
import java.util.stream.Collectors
/**
@jprinet
jprinet / process-scans-for-remote-cache-error.sh
Created August 25, 2023 14:20
Collect builds having push enabled and remote cache disabled due to an error
#!/bin/bash
# Call with
# ./process-scans-for-remote-cache-errors.sh <GE_URL> <GE_ACCESS_TOKEN> <NB_DAYS_FROM_NOW>
# This will count the build scans belonging to the date range [NOW, NOW - <NB_DAYS_FROM_NOW> days] with push enabled and remote cache disabled due to an error
# init parameters
readonly geUrl=$1
readonly bearerToken=$2
readonly daysAgo=$3
@jprinet
jprinet / process-scans.sh
Last active May 15, 2024 19:07
Get list of Github repositories in build scans
#!/bin/bash
# init parameters
readonly geUrl=$1
readonly bearerToken=$2
readonly daysAgo=$3
# init global vars
readonly maxBuildsPerBatch=100
readonly recoveryFile="$0.out.build-scan-id"
@jprinet
jprinet / process-scans.sh
Created August 22, 2023 09:59
Get Git repositories from GE projects
#!/bin/bash
geUrl=$1
bearerToken=$2
since=$3
rm -f $0.out.txt
# We are fetching the first 1000 Gradle builds since $3
gradleBuildScanIds=$(curl "${geUrl}/api/builds?fromInstant=${since}&maxBuilds=1000" --header "authorization: Bearer ${bearerToken}" | jq -r ".[] | select( .buildToolType == \"gradle\") | .id")
for buildScanId in $gradleBuildScanIds; do
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@jprinet
jprinet / CustomGradleEnterpriseConfig.java
Last active June 9, 2023 14:30
Add Docker image IDs as extra inputs to the surefire goal.
package com.gradle;
import com.gradle.maven.extension.api.GradleEnterpriseApi;
import com.gradle.maven.extension.api.cache.BuildCacheApi;
import com.gradle.maven.extension.api.cache.MojoMetadataProvider;
import com.gradle.maven.extension.api.scan.BuildScanApi;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
#!/bin/bash
outputFile=$0.out.csv
rm -f $outputFile
while getopts ":u:t:s:k:v:p:" opt; do
case $opt in
u) geUrl="$OPTARG"
;;
t) bearerToken="$OPTARG"
#!/bin/bash
geUrl=$1
bearerToken=$2
since=$3
customKey=$4
customValue=$5
rm -f $0.out.txt
function processBuilds() {
@jprinet
jprinet / build.gradle.kts
Last active February 9, 2023 10:21
Capture collection fingerprints
val libraryFingerprint by tasks.registering(LibraryFingerprint::class) {
inputFiles.from(sourceSets["main"].output)
}
tasks.named("build").configure {
dependsOn(libraryFingerprint)
}
abstract class LibraryFingerprint : DefaultTask() {
@jprinet
jprinet / build.gradle
Last active September 28, 2022 08:21
Ignore JavaCompile task input differences compilerArgumentProviders.$i.extractedJdkImage
// This normalization block should be combined with the Android cache fix plugin
// https://github.com/gradle/android-cache-fix-gradle-plugin#applying-the-plugin
normalization {
runtimeClasspath {
// See https://github.com/gradle/android-cache-fix-gradle-plugin/issues/341 for more details
ignore '**/java/lang/invoke/**'
}
}