Skip to content

Conversation

@pratap0007
Copy link
Contributor

@pratap0007 pratap0007 commented Sep 25, 2025

Previously, the tkn p start <pipeline_name> --last command was used to rerun a pipeline by referencing the last successful PipelineRun. This worked well for pipelines that were defined and available on the cluster (i.e., when the Pipeline resource existed in the cluster).
However, with resolver-based pipelines, the pipeline definition is not stored as a cluster-scoped resource. Instead, it is dynamically fetched from an external source, such as:

Git resolver – when the pipeline is defined in a Git repository
HTTP resolver – when the pipeline is fetched from a remote HTTP endpoint
Hub resolver – when the pipeline comes from Tekton or Artifact Hub
Bundle resolver – when the pipeline is packaged and retrieved from an OCI bundle
Cluster resolver – when it references a resource within the cluster using the resolver mechanism

Because of this, the existing --last flag did not work for resolver-based pipelines — the CLI had no direct reference to the original resolver configuration (e.g., URL, repository, bundle reference, etc.) used in the previous run.

To address this limitation, this PR introduces a new flag called --resolvertype.
This flag allows users to specify the resolver type (such as git, http, hub, cluster, bundle, and a special type remote resolvers (whan user doesn't know about resolver type they can specify --resolvertype=remote which would be any supported type resolver)) when re-running a resolver-based pipeline.

When provided, the CLI uses the metadata from the last PipelineRun — including the resolver type and its parameters — to reconstruct and trigger a new PipelineRun using the same remote source.

This PR supports these following combinations of flag --last and --resolvertype

  • tkn p <pipeline_name> start –last (existing one)
  • tkn p start <pipeline_name> --last –remotetype=remote
    • pipeline_name is optional and
    • If provides pipeline_name is provided then it searches pipeline on the cluster
  • tkn p start <pipeline_name> –resolvertype=git/http/bundle/cluster/hub
    • pipeline_name is required
  • tkn p start <pipeline_name> –last –remotetype=git/htttp/cluster/bundle/hub
    • pipeline_name is optional
    • if pipeline_name is provided then it searches pipeline on the cluster

closes: #2422

Changes

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

This introduces a new flag called `--resolvertype`. This flag allows users to specify the resolver type (such as `git`, `http`, `hub`, `cluster`, `bundle`, and a special type `remote` resolvers (which would be any supported type resolver)) when re-running a resolver-based pipeline.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 25, 2025
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 25, 2025
@pratap0007
Copy link
Contributor Author

/assign @chmouel @divyansh42

return opt.runWithResolverOnly(cs, pipelineName)
}

func (opt *startOptions) runWithResolverOnly(_ *cli.Clients, pipelineName string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all those methods have a lot of duplications.. any way to streamline this ? by extracting it to a helper method like createObjectMeta(lastPipelineRun, prefixName)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I update it by extracting those in a helper function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@waveywaves
Copy link
Member

/retest

@waveywaves
Copy link
Member

/assign


// Validate resolvertype values
if opt.ResolverType != "" {
validResolvers := []string{"hub", "git", "http", "cluster", "bundles", "remote"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to "bundle" resolver and not bundles

--pipeline-timeout string timeout for PipelineRun
--pod-template string local or remote file containing a PodTemplate definition
--prefix-name string specify a prefix for the PipelineRun name (must be lowercase alphanumeric characters)
--resolvertype string resolver type for remote pipelines (hub, git, http, cluster, bundles, remote)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I am not wrong this is "bundle" resolver and not bundles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the documents and saw pipelineRef.resolver is bundles , should we change it bundle?


.PP
\fB\-\-resolvertype\fP=""
resolver type for remote pipelines (hub, git, http, cluster, bundles, remote)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bundle and not bundles

return opt.runWithResolverOnly(cs, pipelineName)
}

func (opt *startOptions) runWithResolverOnly(_ *cli.Clients, pipelineName string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Re-run the last PipelineRun that used git resolver
tkn pipeline start --last --resolvertype=git -n bar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no pipeline name given

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, pipeline name is optional

test.AssertOutput(t, expected, got)
}

func TestPipelineStart_WithResolver(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing specifically with git resolver so should be named WithGitResolver

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from chmouel after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pratap0007
Copy link
Contributor Author

/retest

- Add --resolvertype flag supporting hub, git, http, cluster, bundle and remote resolver type
- Implement special remote resolver that finds latest PipelineRun with any resolver type and rerun it
- If --resolvertype flag value is except remote, filters pipelinerun by that resolver type
- Integrate --resolvertype with existing --last flag functionality
- With --resolvertype and --last flags pipeline name is optional
- With --last flag pipeline name is optional
- Add validation: resolvertype requires pipeline name except for remote type
- Support all flag combinations: --resolvertype only, --last only, both together
- Include the unit tests

closes: tektoncd#2422

Signed-off-by: Shiv Verma <[email protected]>
@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 23, 2025
@pratap0007
Copy link
Contributor Author

@chmouel I have updated the PR. Could you please review it again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tkn cli support to rerun an existing resolver based pipelinerun

5 participants