@@ -172,6 +172,43 @@ func main() {
172
172
173
173
Action : initialize ,
174
174
},
175
+ {
176
+ Name : "describe" ,
177
+ Subcommands : []cli.Command {
178
+ {
179
+ Name : "pipeline" ,
180
+ Usage : "display pipeline latest build information" ,
181
+ ArgsUsage : "[pipeline-name]" ,
182
+ Before : func (c * cli.Context ) error {
183
+ p := strings .TrimSpace (c .Args ().First ())
184
+ if len (p ) > 0 {
185
+ return requireNameArg (c )
186
+ }
187
+ return nil
188
+ },
189
+ Action : getLatestBuild ,
190
+ },
191
+ },
192
+ },
193
+ {
194
+ Name : "resume" ,
195
+ Usage : "resume pipeline builds" ,
196
+ ArgsUsage : "[pipeline-name]" ,
197
+ Flags : []cli.Flag {
198
+ cli.IntFlag {
199
+ Name : "build, b" ,
200
+ Usage : "Required, Pipeline build number you want to resume" ,
201
+ },
202
+ },
203
+ Before : func (c * cli.Context ) error {
204
+ p := strings .TrimSpace (c .Args ().First ())
205
+ if len (p ) > 0 {
206
+ return requireNameArg (c )
207
+ }
208
+ return nil
209
+ },
210
+ Action : resumeBuild ,
211
+ },
175
212
}
176
213
app .Run (os .Args )
177
214
}
@@ -275,6 +312,48 @@ func getBuilds(c *cli.Context) {
275
312
fmt .Println (table )
276
313
}
277
314
315
+ func getLatestBuild (c * cli.Context ) {
316
+ config , err := apiReq .GetConfigFromFile (c .GlobalString ("conf" ))
317
+ if err != nil {
318
+ os .Exit (1 )
319
+ }
320
+
321
+ owner , repo , _ := parseNameArg (c .Args ().First ())
322
+ pipelineName := fmt .Sprintf ("%s/%s" , owner , repo )
323
+
324
+ pipeline , err := config .GetPipeline (http .DefaultClient , pipelineName )
325
+ if err != nil {
326
+ fmt .Printf ("Pipeline %s doesn't exist \n " , pipelineName )
327
+ os .Exit (1 )
328
+ }
329
+
330
+ stages , _ := config .GetStages (http .DefaultClient , owner , repo , pipeline .LatestBuild .Number )
331
+
332
+ table := uitable .New ()
333
+ table .Wrap = true
334
+
335
+ if pipeline .LatestBuild == nil {
336
+ table .AddRow ("No available builds for pipeline" , pipelineName )
337
+ fmt .Println (table )
338
+ os .Exit (1 )
339
+ }
340
+
341
+ started := time .Unix (0 , pipeline .LatestBuild .Created ).Format (time .RFC3339 )
342
+ finished := time .Unix (0 , pipeline .LatestBuild .Finished ).Format (time .RFC3339 )
343
+
344
+ table .AddRow ("" )
345
+ table .AddRow ("Name:" , pipelineName )
346
+ table .AddRow ("Build No:" , pipeline .LatestBuild .Number )
347
+ table .AddRow ("Status:" , pipeline .LatestBuild .Status )
348
+ table .AddRow ("Author:" , pipeline .LatestBuild .Author )
349
+ table .AddRow ("Started:" , started )
350
+ table .AddRow ("Finished:" , finished )
351
+ table .AddRow ("No of Stages:" , len (stages ))
352
+ table .AddRow ("" )
353
+ fmt .Println (table )
354
+
355
+ }
356
+
278
357
func getStages (c * cli.Context ) {
279
358
config , err := apiReq .GetConfigFromFile (c .GlobalString ("conf" ))
280
359
if err != nil {
@@ -338,8 +417,6 @@ func createBuild(c *cli.Context) {
338
417
339
418
if err != nil {
340
419
fmt .Println (err )
341
- } else {
342
- fmt .Printf ("building pipeline %s/%s " , owner , repo )
343
420
}
344
421
}
345
422
@@ -434,3 +511,24 @@ func removeDeployedApp(c *cli.Context) {
434
511
435
512
fmt .Println ("Success! Kontinuous resources has been removed from the cluster. " )
436
513
}
514
+
515
+ func resumeBuild (c * cli.Context ) {
516
+ config , err := apiReq .GetConfigFromFile (c .GlobalString ("conf" ))
517
+ if err != nil {
518
+ os .Exit (1 )
519
+ }
520
+ owner , repo , _ := parseNameArg (c .Args ().First ())
521
+ buildNo := c .Int ("build" )
522
+
523
+ if owner == "" || repo == "" || buildNo == 0 {
524
+ fmt .Println ("Missing fields." )
525
+ os .Exit (1 )
526
+ }
527
+
528
+ err = config .ResumeBuild (http .DefaultClient , owner , repo , buildNo )
529
+
530
+ if err != nil {
531
+ fmt .Println (err )
532
+ os .Exit (1 )
533
+ }
534
+ }
0 commit comments