You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,9 @@
32
32
importjava.nio.file.Files;
33
33
importjava.nio.file.Path;
34
34
importjava.util.ArrayList;
35
+
importjava.util.Arrays;
35
36
importjava.util.List;
37
+
importjava.util.Optional;
36
38
37
39
importjavax.inject.Inject;
38
40
@@ -142,6 +144,8 @@ public void execute(BuildFinishedFlowAction.Parameters parameters) throws FileNo
142
144
143
145
System.out.println("Generating buildscan link for artifact...");
144
146
147
+
// Output should be in the format: "<UUID><space><ISO-8601-timestamp>\n"
148
+
// and multiple artifacts could be returned
145
149
Processprocess = newProcessBuilder(
146
150
"buildkite-agent",
147
151
"artifact",
@@ -150,7 +154,7 @@ public void execute(BuildFinishedFlowAction.Parameters parameters) throws FileNo
150
154
"--step",
151
155
System.getenv("BUILDKITE_JOB_ID"),
152
156
"--format",
153
-
"%i"
157
+
"%i %c"
154
158
).start();
155
159
process.waitFor();
156
160
StringprocessOutput;
@@ -159,7 +163,17 @@ public void execute(BuildFinishedFlowAction.Parameters parameters) throws FileNo
159
163
} catch (IOExceptione) {
160
164
processOutput = "";
161
165
}
162
-
StringartifactUuid = processOutput.trim();
166
+
167
+
// Sort them by timestamp, and grab the most recent one
168
+
Optional<String> artifact = Arrays.stream(processOutput.trim().split("\n")).map(String::trim).min((a, b) -> {
169
+
String[] partsA = a.split(" ");
170
+
String[] partsB = b.split(" ");
171
+
// ISO-8601 timestamps can be sorted lexicographically
0 commit comments