cloudbuild.proto 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. // Copyright 2016 Google Inc.
  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.cloudbuild.v1;
  16. import "google/api/annotations.proto";
  17. import "google/devtools/source/v1/source_context.proto";
  18. import "google/longrunning/operations.proto";
  19. import "google/protobuf/duration.proto";
  20. import "google/protobuf/empty.proto";
  21. import "google/protobuf/timestamp.proto";
  22. option java_multiple_files = true;
  23. option java_package = "com.google.cloudbuild.v1";
  24. option objc_class_prefix = "GCB";
  25. // Manages container image build requests in the cloud.
  26. //
  27. // The main concept used by this API is a Build, which describes the location of
  28. // the source to build, how to build the source into a container image, and what
  29. // tag to apply to the built image when it is pushed to Google Container
  30. // Registry.
  31. //
  32. // A user can list previously-requested builds or get builds by their ID to
  33. // determine the status of the build.
  34. service CloudBuild {
  35. // Starts a build with the specified configuration.
  36. //
  37. // The long-running Operation returned by this method will include the ID of
  38. // the build, which can be passed to GetBuild to determine its status (e.g.,
  39. // success or failure).
  40. rpc CreateBuild(CreateBuildRequest) returns (google.longrunning.Operation) {
  41. option (google.api.http) = { post: "/v1/projects/{project_id}/builds" body: "build" };
  42. }
  43. // Returns information about a previously requested build.
  44. //
  45. // The Build that is returned includes its status (e.g., success or failure,
  46. // or in-progress), and timing information.
  47. rpc GetBuild(GetBuildRequest) returns (Build) {
  48. option (google.api.http) = { get: "/v1/projects/{project_id}/builds/{id}" };
  49. }
  50. // Lists previously requested builds.
  51. //
  52. // Previously requested builds may still be in-progress, or may have finished
  53. // successfully or unsuccessfully.
  54. rpc ListBuilds(ListBuildsRequest) returns (ListBuildsResponse) {
  55. option (google.api.http) = { get: "/v1/projects/{project_id}/builds" };
  56. }
  57. // Cancels a requested build in progress.
  58. rpc CancelBuild(CancelBuildRequest) returns (Build) {
  59. option (google.api.http) = { post: "/v1/projects/{project_id}/builds/{id}:cancel" body: "*" };
  60. }
  61. // Creates a new BuildTrigger.
  62. //
  63. // This API is experimental.
  64. rpc CreateBuildTrigger(CreateBuildTriggerRequest) returns (BuildTrigger) {
  65. option (google.api.http) = { post: "/v1/projects/{project_id}/triggers" body: "trigger" };
  66. }
  67. // Gets information about a BuildTrigger.
  68. //
  69. // This API is experimental.
  70. rpc GetBuildTrigger(GetBuildTriggerRequest) returns (BuildTrigger) {
  71. option (google.api.http) = { get: "/v1/projects/{project_id}/triggers/{trigger_id}" };
  72. }
  73. // Lists existing BuildTrigger.
  74. //
  75. // This API is experimental.
  76. rpc ListBuildTriggers(ListBuildTriggersRequest) returns (ListBuildTriggersResponse) {
  77. option (google.api.http) = { get: "/v1/projects/{project_id}/triggers" };
  78. }
  79. // Deletes an BuildTrigger by its project ID and trigger ID.
  80. //
  81. // This API is experimental.
  82. rpc DeleteBuildTrigger(DeleteBuildTriggerRequest) returns (google.protobuf.Empty) {
  83. option (google.api.http) = { delete: "/v1/projects/{project_id}/triggers/{trigger_id}" };
  84. }
  85. // Updates an BuildTrigger by its project ID and trigger ID.
  86. //
  87. // This API is experimental.
  88. rpc UpdateBuildTrigger(UpdateBuildTriggerRequest) returns (BuildTrigger) {
  89. option (google.api.http) = { patch: "/v1/projects/{project_id}/triggers/{trigger_id}" body: "trigger" };
  90. }
  91. }
  92. // StorageSource describes the location of the source in an archive file in
  93. // Google Cloud Storage.
  94. message StorageSource {
  95. // Google Cloud Storage bucket containing source (see
  96. // [Bucket Name
  97. // Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
  98. string bucket = 1;
  99. // Google Cloud Storage object containing source.
  100. //
  101. // This object must be a gzipped archive file (.tar.gz) containing source to
  102. // build.
  103. string object = 2;
  104. // Google Cloud Storage generation for the object. If the generation is
  105. // omitted, the latest generation will be used.
  106. int64 generation = 3;
  107. }
  108. // RepoSource describes the location of the source in a Google Cloud Source
  109. // Repository.
  110. message RepoSource {
  111. // ID of the project that owns the repo. If omitted, the project ID requesting
  112. // the build is assumed.
  113. string project_id = 1;
  114. // Name of the repo. If omitted, the name "default" is assumed.
  115. string repo_name = 2;
  116. // A revision within the source repository must be specified in
  117. // one of these ways.
  118. oneof revision {
  119. // Name of the branch to build.
  120. string branch_name = 3;
  121. // Name of the tag to build.
  122. string tag_name = 4;
  123. // Explicit commit SHA to build.
  124. string commit_sha = 5;
  125. }
  126. }
  127. // Source describes the location of the source in a supported storage
  128. // service.
  129. message Source {
  130. // Describes location of source.
  131. oneof source {
  132. // If provided, get the source from this location in in Google Cloud
  133. // Storage.
  134. StorageSource storage_source = 2;
  135. // If provided, get source from this location in a Cloud Repo.
  136. RepoSource repo_source = 3;
  137. }
  138. }
  139. // BuiltImage describes an image built by the pipeline.
  140. message BuiltImage {
  141. // Name used to push the container image to Google Container Registry, as
  142. // presented to `docker push`.
  143. string name = 1;
  144. // Docker Registry 2.0 digest.
  145. string digest = 3;
  146. }
  147. // BuildStep describes a step to perform in the build pipeline.
  148. message BuildStep {
  149. // Name of the container image to use for creating this stage in the
  150. // pipeline, as presented to `docker pull`.
  151. string name = 1;
  152. // Additional environment variables to set for this step's container.
  153. repeated string env = 2;
  154. // Command-line arguments to use when running this step's container.
  155. repeated string args = 3;
  156. // Working directory (relative to project source root) to use when running
  157. // this operation's container.
  158. string dir = 4;
  159. // Optional unique identifier for this build step, used in wait_for to
  160. // reference this build step as a dependency.
  161. string id = 5;
  162. // The ID(s) of the step(s) that this build step depends on.
  163. // This build step will not start until all the build steps in wait_for
  164. // have completed successfully. If wait_for is empty, this build step will
  165. // start when all previous build steps in the Build.Steps list have completed
  166. // successfully.
  167. repeated string wait_for = 6;
  168. }
  169. // Results describes the artifacts created by the build pipeline.
  170. message Results {
  171. // Images that were built as a part of the build.
  172. repeated BuiltImage images = 2;
  173. // List of build step digests, in order corresponding to build step indices.
  174. repeated string build_step_images = 3;
  175. }
  176. // A build resource in the Container Builder API.
  177. //
  178. // At a high level, a Build describes where to find source code, how to build
  179. // it (for example, the builder image to run on the source), and what tag to
  180. // apply to the built image when it is pushed to Google Container Registry.
  181. message Build {
  182. // Possible status of a build.
  183. enum Status {
  184. // Status of the build is unknown.
  185. STATUS_UNKNOWN = 0;
  186. // Build has been received and is being queued.
  187. QUEUING = 8;
  188. // Build is queued; work has not yet begun.
  189. QUEUED = 1;
  190. // Build is being executed.
  191. WORKING = 2;
  192. // Build finished successfully.
  193. SUCCESS = 3;
  194. // Build failed to complete successfully.
  195. FAILURE = 4;
  196. // Build failed due to an internal cause.
  197. INTERNAL_ERROR = 5;
  198. // Build took longer than was allowed.
  199. TIMEOUT = 6;
  200. // Build was canceled by a user.
  201. CANCELLED = 7;
  202. }
  203. // Unique identifier of the build.
  204. // @OutputOnly
  205. string id = 1;
  206. // ID of the project.
  207. // @OutputOnly.
  208. string project_id = 16;
  209. // Status of the build.
  210. // @OutputOnly
  211. Status status = 2;
  212. // Customer-readable message about the current status.
  213. // @OutputOnly
  214. string status_detail = 24;
  215. // Describes where to find the source files to build.
  216. Source source = 3;
  217. // Describes the operations to be performed on the workspace.
  218. repeated BuildStep steps = 11;
  219. // Results of the build.
  220. // @OutputOnly
  221. Results results = 10;
  222. // Time at which the build was created.
  223. // @OutputOnly
  224. google.protobuf.Timestamp create_time = 6;
  225. // Time at which execution of the build was started.
  226. // @OutputOnly
  227. google.protobuf.Timestamp start_time = 7;
  228. // Time at which execution of the build was finished.
  229. // @OutputOnly
  230. google.protobuf.Timestamp finish_time = 8;
  231. // Amount of time that this build should be allowed to run, to second
  232. // granularity. If this amount of time elapses, work on the build will cease
  233. // and the build status will be TIMEOUT.
  234. //
  235. // Default time is ten minutes.
  236. google.protobuf.Duration timeout = 12;
  237. // List of images expected to be built and pushed to Google Container
  238. // Registry. If an image is listed here and the image is not produced by
  239. // one of the build steps, the build will fail. Any images present when
  240. // the build steps are complete will be pushed to Container Registry.
  241. repeated string images = 13;
  242. // Google Cloud Storage bucket where logs should be written (see
  243. // [Bucket Name
  244. // Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
  245. // Logs file names will be of the format `${logs_bucket}/log-${build_id}.txt`.
  246. string logs_bucket = 19;
  247. // A permanent fixed identifier for source.
  248. // @OutputOnly
  249. SourceProvenance source_provenance = 21;
  250. // Special options for this build.
  251. BuildOptions options = 23;
  252. // URL to logs for this build in Google Cloud Logging.
  253. // @OutputOnly
  254. string log_url = 25;
  255. }
  256. // Metadata for build operations.
  257. message BuildOperationMetadata {
  258. // The build that the operation is tracking.
  259. Build build = 1;
  260. }
  261. // Provenance of the source. Ways to find the original source, or verify that
  262. // some source was used for this build.
  263. message SourceProvenance {
  264. // A copy of the build's source.storage_source, if exists, with any
  265. // generations resolved.
  266. StorageSource resolved_storage_source = 3;
  267. // A copy of the build's source.repo_source, if exists, with any
  268. // revisions resolved.
  269. RepoSource resolved_repo_source = 6;
  270. // Hash(es) of the build source, which can be used to verify that the original
  271. // source integrity was maintained in the build. Note that FileHashes will
  272. // only be populated if BuildOptions has requested a SourceProvenanceHash.
  273. //
  274. // The keys to this map are file paths used as build source and the values
  275. // contain the hash values for those files.
  276. //
  277. // If the build source came in a single package such as a gzipped tarfile
  278. // (.tar.gz), the FileHash will be for the single path to that file.
  279. // @OutputOnly
  280. map<string, FileHashes> file_hashes = 4;
  281. }
  282. // Container message for hashes of byte content of files, used in
  283. // SourceProvenance messages to verify integrity of source input to the build.
  284. message FileHashes {
  285. // Collection of file hashes.
  286. repeated Hash file_hash = 1;
  287. }
  288. // Container message for hash values.
  289. message Hash {
  290. // Specifies the hash algorithm, if any.
  291. enum HashType {
  292. // No hash requested.
  293. NONE = 0;
  294. // Use a sha256 hash.
  295. SHA256 = 1;
  296. }
  297. // The type of hash that was performed.
  298. HashType type = 1;
  299. // The hash value.
  300. bytes value = 2;
  301. }
  302. // Request to create a new build.
  303. message CreateBuildRequest {
  304. // ID of the project.
  305. string project_id = 1;
  306. // Build resource to create.
  307. Build build = 2;
  308. }
  309. // Request to get a build.
  310. message GetBuildRequest {
  311. // ID of the project.
  312. string project_id = 1;
  313. // ID of the build.
  314. string id = 2;
  315. }
  316. // Request to list builds.
  317. message ListBuildsRequest {
  318. // ID of the project.
  319. string project_id = 1;
  320. // Number of results to return in the list.
  321. int32 page_size = 2;
  322. // Token to provide to skip to a particular spot in the list.
  323. string page_token = 3;
  324. }
  325. // Response including listed builds.
  326. message ListBuildsResponse {
  327. // Builds will be sorted by create_time, descending.
  328. repeated Build builds = 1;
  329. // Token to receive the next page of results.
  330. string next_page_token = 2;
  331. }
  332. // Request to cancel an ongoing build.
  333. message CancelBuildRequest {
  334. // ID of the project.
  335. string project_id = 1;
  336. // ID of the build.
  337. string id = 2;
  338. }
  339. // Configuration for an automated build in response to source repository
  340. // changes.
  341. message BuildTrigger {
  342. // Unique identifier of the trigger.
  343. //
  344. // @OutputOnly
  345. string id = 1;
  346. // Template describing the types of source changes to trigger a build.
  347. //
  348. // Branch and tag names in trigger templates are interpreted as regular
  349. // expressions. Any branch or tag change that matches that regular expression
  350. // will trigger a build.
  351. RepoSource trigger_template = 7;
  352. // Template describing the Build request to make when the trigger is matched.
  353. //
  354. // Fields can include the following variables which will be expanded when the
  355. // build is created:
  356. // - $PROJECT_ID: the project ID that owns the repo.
  357. // - $REPO_NAME: the name of the repo.
  358. // - $BRANCH_NAME: the branch name that triggered the build.
  359. // - $TAG_NAME: the tag name that triggered the build.
  360. // - $REVISION_ID: the commit SHA of the revision that triggered the build.
  361. oneof build_template {
  362. // Contents of the build template.
  363. Build build = 4;
  364. }
  365. // Time when the trigger was created.
  366. //
  367. // @OutputOnly
  368. google.protobuf.Timestamp create_time = 5;
  369. }
  370. // Request to create a new BuildTrigger.
  371. message CreateBuildTriggerRequest {
  372. // ID of the project for which to configure automatic builds.
  373. string project_id = 1;
  374. // BuildTrigger to create.
  375. BuildTrigger trigger = 2;
  376. }
  377. // Returns the BuildTrigger with the specified ID.
  378. message GetBuildTriggerRequest {
  379. // ID of the project that owns the trigger.
  380. string project_id = 1;
  381. // ID of the BuildTrigger to get.
  382. string trigger_id = 2;
  383. }
  384. // Request to list existing BuildTriggers.
  385. message ListBuildTriggersRequest {
  386. // ID of the project for which to list BuildTriggers.
  387. string project_id = 1;
  388. }
  389. // Response containing existing BuildTriggers.
  390. message ListBuildTriggersResponse {
  391. // BuildTriggers for the project, sorted by create_time descending.
  392. repeated BuildTrigger triggers = 1;
  393. }
  394. // Request to delete a BuildTrigger.
  395. message DeleteBuildTriggerRequest {
  396. // ID of the project that owns the trigger.
  397. string project_id = 1;
  398. // ID of the BuildTrigger to delete.
  399. string trigger_id = 2;
  400. }
  401. // Request to update an existing BuildTrigger.
  402. message UpdateBuildTriggerRequest {
  403. // ID of the project that owns the trigger.
  404. string project_id = 1;
  405. // ID of the BuildTrigger to update.
  406. string trigger_id = 2;
  407. // BuildTrigger to update.
  408. BuildTrigger trigger = 3;
  409. }
  410. // Optional arguments to enable specific features of builds.
  411. message BuildOptions {
  412. // Specifies the manner in which the build should be verified, if at all.
  413. enum VerifyOption {
  414. // Not a verifiable build. (default)
  415. NOT_VERIFIED = 0;
  416. // Verified build.
  417. VERIFIED = 1;
  418. }
  419. // Requested hash for SourceProvenance.
  420. repeated Hash.HashType source_provenance_hash = 1;
  421. // Options for a verifiable build with details uploaded to the Analysis API.
  422. VerifyOption requested_verify_option = 2;
  423. }