Skip to content

Commit c01647d

Browse files
committed
Search for build scan by commit SHA as well as CI run ID
This may not catch build scans based on merge commits created within CI runs, but will catch build scans that have no corresponding GH check run, and will allow the query link we put in reports to catch (some) *future* GH check runs
1 parent 1103078 commit c01647d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/org/hibernate/infra/bot/ExtractDevelocityBuildScans.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.function.Predicate;
1010
import java.util.stream.Collectors;
1111

12-
import com.gradle.develocity.model.BuildAttributesEnvironment;
1312
import jakarta.inject.Inject;
1413

1514
import org.hibernate.infra.bot.config.DeploymentConfig;
@@ -21,6 +20,7 @@
2120

2221
import com.gradle.develocity.api.BuildsApi;
2322
import com.gradle.develocity.model.Build;
23+
import com.gradle.develocity.model.BuildAttributesEnvironment;
2424
import com.gradle.develocity.model.BuildAttributesLink;
2525
import com.gradle.develocity.model.BuildAttributesValue;
2626
import com.gradle.develocity.model.BuildModelName;
@@ -133,6 +133,17 @@ private void extractCIBuildScans(GHRepository repository, RepositoryConfig.Devel
133133
private String createBuildScansQuery(List<GHCheckRun> checkRuns) throws IOException {
134134
Set<String> queries = new HashSet<>();
135135
for ( GHCheckRun checkRun : checkRuns ) {
136+
// This may not catch build scans based on merge commits created within CI runs,
137+
// but will catch build scans that have no corresponding GH check run,
138+
// and will allow the query link we put in reports to catch (some) *future* GH check runs.
139+
var sha = checkRun.getHeadSha();
140+
if ( sha != null && !sha.isBlank() ) {
141+
queries.add( "tag:CI and value:\"Git commit id=%s\"".formatted( sha ) );
142+
}
143+
144+
// This will catch build scans based on merge commits created within CI runs,
145+
// but will not catch build scans that have no corresponding GH check run,
146+
// and will not allow the query link we put in reports to catch *future* GH check runs.
136147
if ( isJenkinsBuild( checkRun ) ) {
137148
var runId = JenkinsRunId.parse( checkRun.getExternalId() );
138149
queries.add( "value:\"CI job=%s\" and value:\"CI build number=%s\""

0 commit comments

Comments
 (0)