publish_build_event.proto 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.devtools.build.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/devtools/build/v1/build_events.proto";
  20. import "google/protobuf/duration.proto";
  21. import "google/protobuf/empty.proto";
  22. option cc_enable_arenas = true;
  23. option go_package = "google.golang.org/genproto/googleapis/devtools/build/v1;build";
  24. option java_multiple_files = true;
  25. option java_outer_classname = "BackendProto";
  26. option java_package = "com.google.devtools.build.v1";
  27. option php_namespace = "Google\\Cloud\\Build\\V1";
  28. // A service for publishing BuildEvents. BuildEvents are generated by Build
  29. // Systems to record actions taken during a Build. Events occur in streams,
  30. // are identified by a StreamId, and ordered by sequence number in a stream.
  31. //
  32. // A Build may contain several streams of BuildEvents, depending on the systems
  33. // that are involved in the Build. Some BuildEvents are used to declare the
  34. // beginning and end of major portions of a Build; these are called
  35. // LifecycleEvents, and are used (for example) to indicate the beginning or end
  36. // of a Build, and the beginning or end of an Invocation attempt (there can be
  37. // more than 1 Invocation in a Build if, for example, a failure occurs somewhere
  38. // and it needs to be retried).
  39. //
  40. // Other, build-tool events represent actions taken by the Build tool, such as
  41. // target objects produced via compilation, tests run, et cetera. There could be
  42. // more than one build tool stream for an invocation attempt of a build.
  43. service PublishBuildEvent {
  44. option (google.api.default_host) = "buildeventservice.googleapis.com";
  45. option (google.api.oauth_scopes) =
  46. "https://www.googleapis.com/auth/cloud-platform";
  47. // Publish a build event stating the new state of a build (typically from the
  48. // build queue). The BuildEnqueued event must be published before all other
  49. // events for the same build ID.
  50. //
  51. // The backend will persist the event and deliver it to registered frontend
  52. // jobs immediately without batching.
  53. //
  54. // The commit status of the request is reported by the RPC's util_status()
  55. // function. The error code is the canoncial error code defined in
  56. // //util/task/codes.proto.
  57. rpc PublishLifecycleEvent(PublishLifecycleEventRequest)
  58. returns (google.protobuf.Empty) {
  59. option (google.api.http) = {
  60. post: "/v1/projects/{project_id=*}/lifecycleEvents:publish"
  61. body: "*"
  62. additional_bindings { post: "/v1/lifecycleEvents:publish" body: "*" }
  63. };
  64. }
  65. // Publish build tool events belonging to the same stream to a backend job
  66. // using bidirectional streaming.
  67. rpc PublishBuildToolEventStream(stream PublishBuildToolEventStreamRequest)
  68. returns (stream PublishBuildToolEventStreamResponse) {
  69. option (google.api.http) = {
  70. post: "/v1/projects/{project_id=*}/events:publish"
  71. body: "*"
  72. additional_bindings { post: "/v1/events:publish" body: "*" }
  73. };
  74. option (google.api.method_signature) =
  75. "ordered_build_event,notification_keywords,project_id";
  76. }
  77. }
  78. // Publishes 'lifecycle events' that update the high-level state of a build:
  79. // - BuildEnqueued: When a build is scheduled.
  80. // - InvocationAttemptStarted: When work for a build starts; there can be
  81. // multiple invocations for a build (e.g. retries).
  82. // - InvocationAttemptCompleted: When work for a build finishes.
  83. // - BuildFinished: When a build is finished.
  84. message PublishLifecycleEventRequest {
  85. // The service level of the build request. Backends only uses this value when
  86. // the BuildEnqueued event is published to determine what level of service
  87. // this build should receive.
  88. enum ServiceLevel {
  89. // Non-interactive builds can tolerate longer event latencies. This is the
  90. // default ServiceLevel if callers do not specify one.
  91. NONINTERACTIVE = 0;
  92. // The events of an interactive build should be delivered with low latency.
  93. INTERACTIVE = 1;
  94. }
  95. // The interactivity of this build.
  96. ServiceLevel service_level = 1;
  97. // Required. The lifecycle build event. If this is a build tool event, the RPC
  98. // will fail with INVALID_REQUEST.
  99. OrderedBuildEvent build_event = 2 [(google.api.field_behavior) = REQUIRED];
  100. // If the next event for this build or invocation (depending on the event
  101. // type) hasn't been published after this duration from when {build_event}
  102. // is written to BES, consider this stream expired. If this field is not set,
  103. // BES backend will use its own default value.
  104. google.protobuf.Duration stream_timeout = 3;
  105. // Additional information about a build request. These are define by the event
  106. // publishers, and the Build Event Service does not validate or interpret
  107. // them. They are used while notifying internal systems of new builds and
  108. // invocations if the OrderedBuildEvent.event type is
  109. // BuildEnqueued/InvocationAttemptStarted.
  110. repeated string notification_keywords = 4;
  111. // Required. The project this build is associated with.
  112. // This should match the project used for the initial call to
  113. // PublishLifecycleEvent (containing a BuildEnqueued message).
  114. string project_id = 6 [(google.api.field_behavior) = REQUIRED];
  115. // Whether to require a previously received matching parent lifecycle event
  116. // for the current request's event before continuing processing.
  117. // - InvocationAttemptStarted and BuildFinished events require a BuildEnqueued
  118. // parent event.
  119. // - InvocationAttemptFinished events require an InvocationAttemptStarted
  120. // parent event.
  121. bool check_preceding_lifecycle_events_present = 7;
  122. }
  123. // States which event has been committed. Any failure to commit will cause
  124. // RPC errors, hence not recorded by this proto.
  125. message PublishBuildToolEventStreamResponse {
  126. // The stream that contains this event.
  127. StreamId stream_id = 1;
  128. // The sequence number of this event that has been committed.
  129. int64 sequence_number = 2;
  130. }
  131. // Build event with contextual information about the stream it belongs to and
  132. // its position in that stream.
  133. message OrderedBuildEvent {
  134. // Which build event stream this event belongs to.
  135. StreamId stream_id = 1;
  136. // The position of this event in the stream. The sequence numbers for a build
  137. // event stream should be a sequence of consecutive natural numbers starting
  138. // from one. (1, 2, 3, ...)
  139. int64 sequence_number = 2;
  140. // The actual event.
  141. BuildEvent event = 3;
  142. }
  143. // Streaming request message for PublishBuildToolEventStream.
  144. message PublishBuildToolEventStreamRequest {
  145. // Required. The build event with position info.
  146. // New publishing clients should use this field rather than the 3 above.
  147. OrderedBuildEvent ordered_build_event = 4
  148. [(google.api.field_behavior) = REQUIRED];
  149. // The keywords to be attached to the notification which notifies the start
  150. // of a new build event stream. BES only reads this field when sequence_number
  151. // or ordered_build_event.sequence_number is 1 in this message. If this field
  152. // is empty, BES will not publish notification messages for this stream.
  153. repeated string notification_keywords = 5;
  154. // Required. The project this build is associated with.
  155. // This should match the project used for the initial call to
  156. // PublishLifecycleEvent (containing a BuildEnqueued message).
  157. string project_id = 6 [(google.api.field_behavior) = REQUIRED];
  158. // Whether to require a previously received matching InvocationAttemptStarted
  159. // event before continuing event processing for the event in the current
  160. // request. BES only performs this check for events with sequence_number 1
  161. // i.e. the first event in the stream.
  162. bool check_preceding_lifecycle_events_present = 7;
  163. }