diff options
author | 2017-04-27 14:56:16 +0200 | |
---|---|---|
committer | 2017-04-27 15:28:25 +0200 | |
commit | 6b76d7332deb4be5d6fdf0a9307ce2177400fa90 (patch) | |
tree | 6cc312dc3836eb42e2c1fcc72cc41ea39bb844c5 /src/main/java/com/google/devtools/build | |
parent | 902af4e05c87ae819ab77da9bee04265bdb264a8 (diff) |
BEP: Report exit code in BuildCompleteEvent
We decided to use the exit code as opposed to a status enum as bazel
reports the build status as an exit code internally and the number of exit
codes is dynamic. That is, a bazel module might add additional exit codes
and thus we need to support reporting these.
The overall_success field is now redundant and has thus been removed. A
build was successfull iff ExitCode.code equals zero.
Change-Id: I268db972b09d983f6cd07df34e3a384efb607358
PiperOrigin-RevId: 154413356
Diffstat (limited to 'src/main/java/com/google/devtools/build')
2 files changed, 27 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto index a59ef39cb3..c4ae568f91 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto @@ -361,8 +361,26 @@ message TestSummary { // Event indicating the end of a build. message BuildFinished { - // If the build succeeded or failed. - bool overall_success = 1; + // Exit code of a build. The possible values correspond to the predefined + // codes in bazel's lib.ExitCode class, as well as any custom exit code a + // module might define. The predefined exit codes are subject to change (but + // rarely do) and are not part of the public API. + // + // A build was successfull iff ExitCode.code equals 0. + message ExitCode { + // The name of the exit code. + string name = 1; + + // The exit code. + int32 code = 2; + } + + reserved 1; + + // The overall status of the build. A build was successfull iff + // ExitCode.code equals 0. + ExitCode exit_code = 3; + // Time in milliseconds since the epoch. // TODO(buchgr): Use google.protobuf.Timestamp once bazel's protoc supports // it. diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java index f8e419e65f..936aeb12a5 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java @@ -60,9 +60,15 @@ public final class BuildCompleteEvent implements BuildEvent { @Override public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) { + BuildEventStreamProtos.BuildFinished.ExitCode exitCode = + BuildFinished.ExitCode.newBuilder() + .setName(result.getExitCondition().name()) + .setCode(result.getExitCondition().getNumericExitCode()) + .build(); + BuildFinished finished = BuildFinished.newBuilder() - .setOverallSuccess(result.getSuccess()) + .setExitCode(exitCode) .setFinishTimeMillis(result.getStopTime()) .build(); return GenericBuildEvent.protoChaining(this).setFinished(finished).build(); |