1
- const request = require ( 'request-promise ' ) ;
1
+ const got = require ( 'got ' ) ;
2
2
3
3
class Codefresh {
4
4
/**
5
5
*
6
- * @return {{build: {trigger: *, initiator: *, id: *, timestamp: *, url: *}, repo: {owner: *, name: *}, commit: {author: *, url: *, message: *}, revision: *, branch: *, apiKey: *} }
6
+ * @return {{
7
+ * build: {trigger: *, initiator: *, id: *, timestamp: *, url: *},
8
+ * repo: {owner: *, name: *},
9
+ * commit: {author: *, url: *, message: *},
10
+ * revision: *,
11
+ * branch: *,
12
+ * apiKey: *
13
+ * }}
7
14
*/
8
15
get info ( ) {
9
16
return {
@@ -26,20 +33,22 @@ class Codefresh {
26
33
revision : process . env . CF_REVISION ,
27
34
branch : process . env . CF_BRANCH_TAG_NORMALIZED ,
28
35
apiKey : process . env . CF_API_KEY ,
29
- cfUrl : process . env . CF_URL
36
+ cfUrl : process . env . CF_URL ,
30
37
} ;
31
38
}
32
39
33
40
async buildFailureCauses ( buildId , token , cfUrl ) {
34
41
console . log ( token , buildId ) ;
35
- const data = await request ( {
36
- uri : `${ cfUrl } /api/workflow/${ buildId } /context-revision` ,
37
- method : 'GET' ,
38
- headers : {
39
- 'authorization' : token ,
42
+
43
+ const data = await got (
44
+ {
45
+ url : `${ cfUrl } /api/workflow/${ buildId } /context-revision` ,
46
+ method : 'GET' ,
47
+ headers : {
48
+ authorization : token ,
49
+ } ,
40
50
} ,
41
- json : true ,
42
- } ) ;
51
+ ) . json ( ) ;
43
52
44
53
return Object . entries ( data . pop ( ) . context . stepsMetadata )
45
54
. filter ( ( [ , stepInfo ] ) => stepInfo . status === 'failure' )
0 commit comments