Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflect state of started pipeline/task when using --showlog #1880

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pkg/cmd/pipeline/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"strings"
"time"

"knative.dev/pkg/apis"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -414,7 +416,22 @@ func (opt *startOptions) startPipeline(pipelineStart *v1beta1.Pipeline) error {
Params: opt.cliparams,
AllSteps: false,
}
return prcmd.Run(runLogOpts)
if err = prcmd.Run(runLogOpts); err != nil {
return err
}

// Fetch the PipelineRun to get the PipelineRun status
prLatest, err := pipelinerun.GetPipelineRun(pipelineRunGroupResource, cs, prCreated.Name, prCreated.Namespace)
if err != nil {
return err
}

// If PipelineRun status is not Succeeded, print the PipelineRun status
if prLatest.Status.GetCondition(apis.ConditionSucceeded).IsFalse() {
return fmt.Errorf("pipelinerun %s did not succeed", prLatest.Name)
}

return nil
}

func (opt *startOptions) getInput(pipeline *v1beta1.Pipeline) error {
Expand Down
18 changes: 17 additions & 1 deletion pkg/cmd/task/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,23 @@ func startTask(opt startOptions, args []string) error {
Params: opt.cliparams,
AllSteps: false,
}
return taskrun.Run(runLogOpts)

if err := taskrun.Run(runLogOpts); err != nil {
return err
}

// fetch the taskrun again to get the latest status
trLatest, err := traction.GetTaskRun(taskrunGroupResource, cs, trCreated.Name, trCreated.Namespace)
if err != nil {
return err
}

// check if the created taskrun succeed or not
if !trLatest.IsSuccessful() {
return fmt.Errorf("taskRun %s did not succeed", trCreated.Name)
}

return nil
}

func printTaskRun(output string, s *cli.Stream, tr interface{}) error {
Expand Down
Loading