File tree Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Original file line number Diff line number Diff line change 1
- name : new-pipeline
2
- account : 59d33c4e9f75220a3710b2ee
1
+ name : new-pipeline-url
2
+ # account: 59d33c4e9f75220a3710b2ee
3
3
metadata :
4
4
labels :
5
5
repo : github:ArikMaor/ping-server
9
9
repo : ArikMaor/ping-server
10
10
events : [push, pullrequest]
11
11
branchRegex : ' .'
12
- contexts : ['lala' ]
12
+ contexts : []
13
13
variables :
14
14
- key : PORT
15
15
value : 3000
19
19
encrypted : true
20
20
source :
21
21
location : url
22
- url : https://raw.githubusercontent.csom/ArikMaor/ping-server /master/codefresh.yml
22
+ url : https://raw.githubusercontent.com/codefresh-io/cli /master/codefresh.yml
Original file line number Diff line number Diff line change 1
1
name : new-pipeline
2
- account : 59d33c4e9f75220a3710b2ee
2
+ # account: 59d33c4e9f75220a3710b2ee
3
3
metadata :
4
4
labels :
5
5
repo : github:ArikMaor/ping-server
9
9
repo : ArikMaor/ping-server
10
10
events : [push, pullrequest]
11
11
branchRegex : ' .'
12
- contexts : ['lala' ]
12
+ contexts : []
13
13
variables :
14
14
- key : PORT
15
15
value : 3000
Original file line number Diff line number Diff line change @@ -80,6 +80,24 @@ const run = new Command({
80
80
}
81
81
}
82
82
83
+ let pipelineVersion = 'v1' ;
84
+ if ( authManager . getCurrentContext ( )
85
+ . isBetaFeatEnabled ( ) ) {
86
+ try {
87
+ await pipeline . getPipelineById ( pipelineId ) ;
88
+ } catch ( err ) {
89
+ try {
90
+ await pipeline2 . getPipelineByName ( pipelineId ) ;
91
+ pipelineVersion = 'v2' ;
92
+ } catch ( err ) {
93
+ throw new CFError ( {
94
+ message : `Passed pipeline id: ${ pipelineId } does not exist` ,
95
+ } ) ;
96
+ }
97
+ }
98
+ }
99
+
100
+
83
101
const executionRequests = [ ] ;
84
102
const executionRequestTemplate = {
85
103
pipelineId,
@@ -106,10 +124,10 @@ const run = new Command({
106
124
107
125
_ . forEach ( executionRequests , async ( { pipelineId, options } ) => {
108
126
let workflowId ;
109
- if ( ! ObjectID . isValid ( pipelineId ) ) {
110
- workflowId = await pipeline2 . runPipelineByName ( pipelineId , options ) ;
111
- } else {
127
+ if ( pipelineVersion === 'v1' ) {
112
128
workflowId = await pipeline . runPipelineById ( pipelineId , options ) ;
129
+ } else {
130
+ workflowId = await pipeline2 . runPipelineByName ( pipelineId , options ) ;
113
131
}
114
132
115
133
if ( executionRequests . length === 1 ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const createRoot = require('../root/create.cmd');
9
9
const command = new Command ( {
10
10
betaCommand : true ,
11
11
command : 'pipeline2 [name]' ,
12
+ aliases : [ 'pip2' ] ,
12
13
parent : createRoot ,
13
14
cliDocs : {
14
15
description : 'Create a pipeline' ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const deleteRoot = require('../root/delete.cmd');
10
10
const command = new Command ( {
11
11
betaCommand : true ,
12
12
command : 'pipeline2 [name]' ,
13
+ aliases : [ 'pip2' ] ,
13
14
parent : deleteRoot ,
14
15
cliDocs : {
15
16
description : 'Delete a pipeline' ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const replaceRoot = require('../root/replace.cmd');
9
9
const command = new Command ( {
10
10
betaCommand : true ,
11
11
command : 'pipeline2 [name]' ,
12
+ aliases : [ 'pip2' ] ,
12
13
parent : replaceRoot ,
13
14
cliDocs : {
14
15
description : 'Replace a pipeline' ,
Original file line number Diff line number Diff line change @@ -3,14 +3,26 @@ const CFError = require('cf-errors'); // eslint-disable-line
3
3
const { sendHttpRequest } = require ( './helper' ) ;
4
4
const Pipeline = require ( '../entities/Pipeline2' ) ;
5
5
6
+ const _extractFieldsForPipelineEntity = pipeline => ( {
7
+ id : pipeline . _id ,
8
+ name : pipeline . name ,
9
+ spec : pipeline . spec ,
10
+ } ) ;
11
+
6
12
const getAll = async ( ) => {
7
13
const options = {
8
14
url : '/api/pipelines/new' ,
9
15
method : 'GET' ,
10
16
} ;
11
17
12
- const pipelines = await sendHttpRequest ( options ) ;
13
- return pipelines . map ( p => new Pipeline ( p ) ) ;
18
+ const result = await sendHttpRequest ( options ) ;
19
+ const pipelines = [ ] ;
20
+ _ . forEach ( result , ( pipeline ) => {
21
+ const data = _extractFieldsForPipelineEntity ( pipeline ) ;
22
+ pipelines . push ( new Pipeline ( data ) ) ;
23
+ } ) ;
24
+
25
+ return pipelines ;
14
26
} ;
15
27
16
28
const getPipelineByName = async ( name ) => {
@@ -19,8 +31,9 @@ const getPipelineByName = async (name) => {
19
31
method : 'GET' ,
20
32
} ;
21
33
22
- const pipeline = await sendHttpRequest ( options ) ;
23
- return new Pipeline ( pipeline ) ;
34
+ const result = await sendHttpRequest ( options ) ;
35
+ const data = _extractFieldsForPipelineEntity ( result ) ;
36
+ return new Pipeline ( data ) ;
24
37
} ;
25
38
26
39
const createPipeline = async ( data ) => {
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ class Pipeline2 extends Entity {
5
5
super ( ) ;
6
6
this . entityType = 'pipeline2' ;
7
7
this . info = data ;
8
- this . defaultColumns = [ 'id' , 'name' , 'imageName' ] ;
9
- this . wideColumns = [ 'id' , 'name' , 'imageName' ] ;
8
+ this . defaultColumns = [ 'id' , 'name' ] ;
9
+ this . wideColumns = this . defaultColumns . concat ( [ ] ) ;
10
10
}
11
11
}
12
12
You can’t perform that action at this time.
0 commit comments