diff --git a/docs/cmd/tkn_pipeline_start.md b/docs/cmd/tkn_pipeline_start.md index 8f80dfb67..02dd33549 100644 --- a/docs/cmd/tkn_pipeline_start.md +++ b/docs/cmd/tkn_pipeline_start.md @@ -47,6 +47,7 @@ two parameters (foo and bar) -s, --serviceaccount string pass the serviceaccount name --showlog show logs right after starting the pipeline --task-serviceaccount strings pass the service account corresponding to the task + --timeout string timeout for pipelinerun (default "1h") --use-pipelinerun string use this pipelinerun values to re-run the pipeline. ``` diff --git a/docs/man/man1/tkn-pipeline-start.1 b/docs/man/man1/tkn-pipeline-start.1 index 8c56342d2..0e6a6f98c 100644 --- a/docs/man/man1/tkn-pipeline-start.1 +++ b/docs/man/man1/tkn-pipeline-start.1 @@ -71,6 +71,10 @@ Parameters, at least those that have no default value \fB\-\-task\-serviceaccount\fP=[] pass the service account corresponding to the task +.PP +\fB\-\-timeout\fP="1h" + timeout for pipelinerun + .PP \fB\-\-use\-pipelinerun\fP="" use this pipelinerun values to re\-run the pipeline. diff --git a/pkg/cmd/pipeline/start.go b/pkg/cmd/pipeline/start.go index 1cd6ed936..5bd4b20b1 100644 --- a/pkg/cmd/pipeline/start.go +++ b/pkg/cmd/pipeline/start.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "strings" + "time" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -67,6 +68,7 @@ type startOptions struct { DryRun bool Output string PrefixName string + TimeOut string } type resourceOptionsFilter struct { @@ -161,6 +163,7 @@ like cat,foo,bar c.Flags().BoolVarP(&opt.DryRun, "dry-run", "", false, "preview pipelinerun without running it") c.Flags().StringVarP(&opt.Output, "output", "", "", "format of pipelinerun dry-run (yaml or json)") c.Flags().StringVarP(&opt.PrefixName, "prefix-name", "", "", "specify a prefix for the pipelinerun name (must be lowercase alphanumeric characters)") + c.Flags().StringVarP(&opt.TimeOut, "timeout", "", "1h", "timeout for pipelinerun") _ = c.MarkZshCompPositionalArgumentCustom(1, "__tkn_get_pipeline") @@ -413,6 +416,12 @@ func (opt *startOptions) startPipeline(pName string) error { }, } + timeoutDuration, err := time.ParseDuration(opt.TimeOut) + if err != nil { + return err + } + pr.Spec.Timeout = &metav1.Duration{Duration: timeoutDuration} + cs, err := opt.cliparams.Clients() if err != nil { return err @@ -485,7 +494,7 @@ func (opt *startOptions) startPipeline(pName string) error { return nil } - fmt.Fprintf(opt.stream.Out, "Showing logs...\n") + fmt.Fprintf(opt.stream.Out, "Waiting for logs to be available...\n") runLogOpts := &options.LogOptions{ PipelineName: pName, PipelineRunName: prCreated.Name, diff --git a/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_only_--dry-run_specified.golden b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_only_--dry-run_specified.golden index 61834caa2..5f8046f5f 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_only_--dry-run_specified.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_only_--dry-run_specified.golden @@ -17,4 +17,5 @@ spec: resourceRef: name: scaffold-git serviceAccountName: svc1 + timeout: 1h0m0s status: {} diff --git a/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_output=json.golden b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_output=json.golden index 6633945c2..0e9f7d2c1 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_output=json.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_output=json.golden @@ -27,7 +27,8 @@ "value": "value1" } ], - "serviceAccountName": "svc1" + "serviceAccountName": "svc1", + "timeout": "1h0m0s" }, "status": {} }