Skip to content

feat : add structured JSON input for start commands#2925

Open
vikashkumar2020 wants to merge 3 commits into
tektoncd:mainfrom
vikashkumar2020:feat/start-cmd-json
Open

feat : add structured JSON input for start commands#2925
vikashkumar2020 wants to merge 3 commits into
tektoncd:mainfrom
vikashkumar2020:feat/start-cmd-json

Conversation

@vikashkumar2020

Copy link
Copy Markdown

Changes

Add a --json flag to tkn pipeline start and tkn task start so users can provide a PipelineRunSpec or TaskRunSpec as JSON.

The flag supports:

  • inline JSON
  • to read JSON from stdin
  • @path to read JSON from a file

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

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 27, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 27, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 27, 2026
@vikashkumar2020 vikashkumar2020 changed the title Feat/start cmd json feat : add structured JSON input for start commands Jun 27, 2026
@chmouel

chmouel commented Jun 29, 2026

Copy link
Copy Markdown
Member

is it possible to add json output too ?

@vikashkumar2020

Copy link
Copy Markdown
Author

is it possible to add json output too ?

pipeline :


apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: demo-pipeline
spec:
  params:
    - name: foo
      type: string
      default: default-value
  tasks:
    - name: echo
      taskSpec:
        params:
          - name: foo
            type: string
        steps:
          - name: echo
            image: bash:latest
            script: |
              echo "$(params.foo)"
      params:
        - name: foo
          value: "$(params.foo)"

cmd

./tkn pipeline start demo-pipeline --json '{"params":[{"name":"foo","value":"hello-json"}]}'

output

{
	"kind": "PipelineRun",
	"apiVersion": "tekton.dev/v1",
	"metadata": {
		"generateName": "demo-pipeline-run-",
		"namespace": "default"
	},
	"spec": {
		"pipelineRef": {
			"name": "demo-pipeline"
		},
		"params": [
			{
				"name": "foo",
				"value": "hello-json"
			}
		],
		"taskRunTemplate": {}
	},
	"status": {}
}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new --json flag to tkn task start and tkn pipeline start so users can provide structured JSON to populate parts of the generated TaskRun/PipelineRun spec (supporting inline JSON, stdin via -, and file via @path). This fits into the CLI’s start-command workflow by augmenting the existing flag/interactive inputs and updating the generated docs accordingly.

Changes:

  • Introduces --json flag handling in task/pipeline start commands (inline / stdin / @file).
  • Merges selected JSON *RunSpec fields into the generated TaskRun / PipelineRun objects and skips interactive prompting when --json is set.
  • Adds unit/integration-style tests and updates generated markdown + manpage docs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/cmd/task/start.go Adds --json flag, JSON resolution, and merges JSON spec fields into TaskRun.
pkg/cmd/task/start_test.go Adds coverage for --json (inline/malformed/missing file) plus readJSONSpec tests.
pkg/cmd/pipeline/start.go Adds --json flag, JSON resolution, and merges JSON spec fields into PipelineRun.
pkg/cmd/pipeline/start_test.go Adds coverage for --json (inline/malformed/missing file) plus readJSONSpec tests.
docs/man/man1/tkn-task-start.1 Documents new --json flag for task start.
docs/man/man1/tkn-pipeline-start.1 Documents new --json flag for pipeline start.
docs/cmd/tkn_task_start.md Updates generated markdown docs with --json.
docs/cmd/tkn_pipeline_start.md Updates generated markdown docs with --json.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/cmd/task/start.go Outdated
Comment on lines +412 to +416
if opt.JSONSpec != "" {
if err := applyTaskRunJSONSpec(tr, opt.JSONSpec, os.Stdin); err != nil {
return err
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated

Comment thread pkg/cmd/task/start.go
c.Flags().BoolVarP(&opt.UseParamDefaults, "use-param-defaults", "", false, "use default parameter values without prompting for input")
c.Flags().StringVar(&opt.PodTemplate, "pod-template", "", "local or remote file containing a PodTemplate definition")
c.Flags().BoolVarP(&opt.SkipOptionalWorkspace, "skip-optional-workspace", "", false, "skips the prompt for optional workspaces")
c.Flags().StringVar(&opt.JSONSpec, "json", "", "TaskRun spec as JSON (inline, '-' for stdin, or '@path' for a file)")
Comment thread pkg/cmd/pipeline/start.go
},
)

c.Flags().StringVar(&opt.JSONSpec, "json", "", "PipelineRun spec as JSON (inline, '-' for stdin, or '@path' for a file)")
@tekton-robot

Copy link
Copy Markdown
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 vdemeester after the PR has been reviewed.

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

Details 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

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants