1
- /**
2
- * Copyright 2019, Google, LLC.
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
- * /
1
+ // Copyright 2019 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
+ // https ://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
+ / /
15
15
16
16
'use strict' ;
17
17
@@ -28,17 +28,33 @@ async function quickstart(
28
28
const cb = new CloudBuildClient ( ) ;
29
29
30
30
// Starts a build against the branch provided.
31
- const request = {
31
+ const [ resp ] = await cb . runBuildTrigger ( {
32
32
projectId,
33
33
triggerId,
34
34
source : {
35
- projectId : projectId ,
35
+ projectId,
36
36
dir : './' ,
37
37
branchName,
38
38
} ,
39
- } ;
40
- await cb . runBuildTrigger ( request ) ;
39
+ } ) ;
41
40
console . info ( `triggered build for ${ triggerId } ` ) ;
41
+ const [ build ] = await resp . promise ( ) ;
42
+
43
+ const STATUS_LOOKUP = [
44
+ 'UNKNOWN' ,
45
+ 'Queued' ,
46
+ 'Working' ,
47
+ 'Success' ,
48
+ 'Failure' ,
49
+ 'Error' ,
50
+ 'Timeout' ,
51
+ 'Cancelled' ,
52
+ ] ;
53
+ for ( const step of build . steps ) {
54
+ console . info (
55
+ `step:\n\tname: ${ step . name } \n\tstatus: ${ STATUS_LOOKUP [ build . status ] } `
56
+ ) ;
57
+ }
42
58
}
43
59
// [END cloudbuild_quickstart]
44
60
0 commit comments