Skip to content

Commit ef42c61

Browse files
feat: Add ability to configure BuildTriggers to create Builds that require approval before executing and ApproveBuild API to approve or reject pending Builds (#267)
Comitter: @joonlim PiperOrigin-RevId: 391072303 Source-Link: googleapis/googleapis@7fec729 Source-Link: googleapis/googleapis-gen@22f5dc3
1 parent 95cf186 commit ef42c61

File tree

8 files changed

+2161
-0
lines changed

8 files changed

+2161
-0
lines changed

packages/google-devtools-cloudbuild/protos/google/devtools/cloudbuild/v1/cloudbuild.proto

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,28 @@ service CloudBuild {
176176
};
177177
}
178178

179+
// Approves or rejects a pending build.
180+
//
181+
// If approved, the returned LRO will be analogous to the LRO returned from
182+
// a CreateBuild call.
183+
//
184+
// If rejected, the returned LRO will be immediately done.
185+
rpc ApproveBuild(ApproveBuildRequest) returns (google.longrunning.Operation) {
186+
option (google.api.http) = {
187+
post: "/v1/{name=projects/*/builds/*}:approve"
188+
body: "*"
189+
additional_bindings {
190+
post: "/v1/{name=projects/*/locations/*/builds/*}:approve"
191+
body: "*"
192+
}
193+
};
194+
option (google.api.method_signature) = "name,approval_result";
195+
option (google.longrunning.operation_info) = {
196+
response_type: "Build"
197+
metadata_type: "BuildOperationMetadata"
198+
};
199+
}
200+
179201
// Creates a new `BuildTrigger`.
180202
//
181203
// This API is experimental.
@@ -720,6 +742,10 @@ message Build {
720742
// Status of the build is unknown.
721743
STATUS_UNKNOWN = 0;
722744

745+
// Build has been created and is pending execution and queuing. It has not
746+
// been queued.
747+
PENDING = 10;
748+
723749
// Build or step is queued; work has not yet begun.
724750
QUEUED = 1;
725751

@@ -863,6 +889,10 @@ message Build {
863889
// these keys will not be included.
864890
map<string, TimeSpan> timing = 33 [(google.api.field_behavior) = OUTPUT_ONLY];
865891

892+
// Output only. Describes this build's approval configuration, status,
893+
// and result.
894+
BuildApproval approval = 44 [(google.api.field_behavior) = OUTPUT_ONLY];
895+
866896
// IAM service account whose credentials will be used at build runtime.
867897
// Must be of the format `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}`.
868898
// ACCOUNT can be email address or uniqueId of the service account.
@@ -1145,6 +1175,92 @@ message CancelBuildRequest {
11451175
string id = 2 [(google.api.field_behavior) = REQUIRED];
11461176
}
11471177

1178+
// Request to approve or reject a pending build.
1179+
message ApproveBuildRequest {
1180+
// Required. Name of the target build.
1181+
// For example: "projects/{$project_id}/builds/{$build_id}"
1182+
string name = 1 [(google.api.field_behavior) = REQUIRED];
1183+
1184+
// Approval decision and metadata.
1185+
ApprovalResult approval_result = 2;
1186+
}
1187+
1188+
// BuildApproval describes a build's approval configuration, state, and
1189+
// result.
1190+
message BuildApproval {
1191+
// Specifies the current state of a build's approval.
1192+
enum State {
1193+
// Default enum type. This should not be used.
1194+
STATE_UNSPECIFIED = 0;
1195+
1196+
// Build approval is pending.
1197+
PENDING = 1;
1198+
1199+
// Build approval has been approved.
1200+
APPROVED = 2;
1201+
1202+
// Build approval has been rejected.
1203+
REJECTED = 3;
1204+
1205+
// Build was cancelled while it was still pending approval.
1206+
CANCELLED = 5;
1207+
}
1208+
1209+
// Output only. The state of this build's approval.
1210+
State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
1211+
1212+
// Output only. Configuration for manual approval of this build.
1213+
ApprovalConfig config = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
1214+
1215+
// Output only. Result of manual approval for this Build.
1216+
ApprovalResult result = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
1217+
}
1218+
1219+
// ApprovalConfig describes configuration for manual approval of a build.
1220+
message ApprovalConfig {
1221+
// Whether or not approval is needed. If this is set on a build, it will
1222+
// become pending when created, and will need to be explicitly approved
1223+
// to start.
1224+
bool approval_required = 1;
1225+
}
1226+
1227+
// ApprovalResult describes the decision and associated metadata of a manual
1228+
// approval of a build.
1229+
message ApprovalResult {
1230+
// Specifies whether or not this manual approval result is to approve
1231+
// or reject a build.
1232+
enum Decision {
1233+
// Default enum type. This should not be used.
1234+
DECISION_UNSPECIFIED = 0;
1235+
1236+
// Build is approved.
1237+
APPROVED = 1;
1238+
1239+
// Build is rejected.
1240+
REJECTED = 2;
1241+
}
1242+
1243+
// Output only. Email of the user that called the ApproveBuild API to
1244+
// approve or reject a build at the time that the API was called.
1245+
string approver_account = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
1246+
1247+
// Output only. The time when the approval decision was made.
1248+
google.protobuf.Timestamp approval_time = 3
1249+
[(google.api.field_behavior) = OUTPUT_ONLY];
1250+
1251+
// Required. The decision of this manual approval.
1252+
Decision decision = 4 [(google.api.field_behavior) = REQUIRED];
1253+
1254+
// Optional. An optional comment for this manual approval result.
1255+
string comment = 5 [(google.api.field_behavior) = OPTIONAL];
1256+
1257+
// Optional. An optional URL tied to this manual approval result. This field
1258+
// is essentially the same as comment, except that it will be rendered by the
1259+
// UI differently. An example use case is a link to an external job that
1260+
// approved this Build.
1261+
string url = 6 [(google.api.field_behavior) = OPTIONAL];
1262+
}
1263+
11481264
// Configuration for an automated build in response to source repository
11491265
// changes.
11501266
message BuildTrigger {

0 commit comments

Comments
 (0)