Skip to content

Commit 1a3ae94

Browse files
authored
Fix examples for servers with varied build tools (#433)
If the Develocity server from which builds are being fetched contains build scans of build tools other than Gradle, such as Maven, the `gradleAttributes` model will be null. While the examples could check it for null, filtering these out from the query is more efficient.
1 parent cc4638e commit 1a3ae94

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

examples/example-notebooks/MostFrequentBuilds.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"val builds: List<GradleAttributes> = runBlocking {\n",
115115
" api.buildsApi.getBuildsFlow(\n",
116116
" fromInstant = 0,\n",
117-
" query = \"\"\"buildStartTime>-7d\"\"\",\n",
117+
" query = \"\"\"buildStartTime>-7d buildTool:gradle\"\"\",\n",
118118
" models = listOf(BuildModelName.gradleAttributes),\n",
119119
" ).map {\n",
120120
" it.models!!.gradleAttributes!!.model!!\n",

examples/example-project/src/main/kotlin/com/gabrielfeo/develocity/api/example/analysis/MostFrequentBuilds.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ suspend fun mostFrequentBuilds(
2727
// Fetch builds from the API
2828
val builds: List<GradleAttributes> = api.getBuildsFlow(
2929
fromInstant = 0,
30-
query = """buildStartTime>$startTime""",
30+
query = """buildStartTime>$startTime buildTool:gradle""",
3131
models = listOf(BuildModelName.gradleAttributes),
3232
).map {
3333
it.models!!.gradleAttributes!!.model!!

examples/example-scripts/example-script.main.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ val api = DevelocityApi.newInstance()
3838
val builds: List<GradleAttributes> = runBlocking {
3939
api.buildsApi.getBuildsFlow(
4040
fromInstant = 0,
41-
query = """buildStartTime>-7d""",
41+
query = """buildStartTime>-7d buildTool:gradle""",
4242
models = listOf(BuildModelName.gradleAttributes),
4343
).map {
4444
it.models!!.gradleAttributes!!.model!!

0 commit comments

Comments
 (0)