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

Dynamic Input Parameters #552

Closed
warrenbailey opened this issue Feb 26, 2019 · 7 comments
Closed

Dynamic Input Parameters #552

warrenbailey opened this issue Feb 26, 2019 · 7 comments
Labels
design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given

Comments

@warrenbailey
Copy link

warrenbailey commented Feb 26, 2019

Expected Behavior

I'm building a release pipeline for one of our projects and ideally I want to pass a dynamically created value between two tasks. I want the first task to generate the 'release version' and do the git tags etc. Then the second tasks (which is Kaniko) to build the image and push it to the docker registry with the released version from the first task as a tag.

I know it's possible to have input parameters but the value of these need to be defined upfront in the pipeline run files but in this scenario they are not known at that point. I also had a look at pipeline resources but the only thing a task seems to be able to output is an image or file. It would be great if it could output a variable.

Actual Behavior

None - new feature suggestion

Steps to Reproduce the Problem

  1. Create a Task that writes generates info required for a future task, e.g. this Task will write a version value to a file as json (this is a detail of the design and open to change)
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: create-version
spec:
  inputs:
    resources:
      params:
      - name: currentVersion
        description: The current version as just a single number for this trivial example
  outputs:
    resources:
    - name: version
      type: keyValue # also a detail of the design and open to change
  steps:
  - name: write-new-num
    image: ubuntu
    command:
    - /bin/bash
    args:
    - -c
    - "echo \"{ \\"version\\": $((5 + 3)) }\" > /workspace/version/keyvalue" 
  1. Create another Task that uses that value
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: echo-version
spec:
  inputs:
    resources:
    - name: version
      type: keyValue
  outputs:
  steps:
  - name: echo-version
    image: ubuntu
    command:
    - echo
    args:
    - "${inputs.resources.version.version}" # also a design detail open to change
  1. Link them together in a Pipeline:
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: demo-pipeline
spec:
  resources:
  - name: version-key-value
    type: keyvalue
  tasks:
  - name: make-version
    taskRef:
      name: create-version
    params:
    - name: currentVersion
      value: 5
    resources:
      outputs:
      - name: version
        resource: version-key-value
  - name: output-the-version
    taskRef:
      name: echo-version
    resources:
      inputs:
      - name: version
        resource: version-key-value
        from: [make-version]
  1. Create a PipelineRun to run the Pipeline
  2. The goal would be that the first Task could generate a Version which could be echoed by the next one

Additional Info

Related to functionality needed for #216

@abayer
Copy link
Contributor

abayer commented Feb 26, 2019

/assign

@bobcatfish
Copy link
Collaborator

@warrenbailey I added a "steps to reproduce" section which tries to sketch out the functionality you're looking for, is that accurate?

The example assumes a design we don't have to be tied to:

  1. There's a keyvalue Resource type
  2. Tasks can output keyvalue Resoruces by writing a json map to a certain location

@bobcatfish
Copy link
Collaborator

btw @abayer we can probably share some logic between this and #216 (the logic for how we get values from an executing container back to the controller)

@bobcatfish bobcatfish added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. design This task is about creating and discussing a design meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given labels Feb 27, 2019
@abayer
Copy link
Contributor

abayer commented Feb 27, 2019

@bobcatfish Yes! #216 is exactly the same sorta thing.

@warrenbailey
Copy link
Author

@bobcatfish yes that's exactly what I want 👍

@fgiloux
Copy link
Contributor

fgiloux commented Oct 8, 2019

This would also be required to allow human interactions as part of a pipeline, something like the input step in Jenkins [1]. It would then be possible to create a task, which supports the human interaction (presenting a web form for instance) and populate the parameters according to the user input.

[1] https://jenkins.io/doc/pipeline/steps/pipeline-input-step/

@bobcatfish
Copy link
Collaborator

Wow I forgot about this issue! We ended up having the request again: #1273 and Tasks can now declare results. The next step is to link these in a Pipeline (#1950) using a very similar syntax to @warrenbailey 's proposal above!

Closing this issue in favor of #1950

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given
Projects
None yet
Development

No branches or pull requests

4 participants