-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Support referencing task results from task params in a pipeline #1978
Comments
@sbwsg The idea of inferring task order based on the from seems like a cool idea. Another options which will keep things simple this first round is require(via validation) that all tasks mentioned in the We can then come back and drop this requirement for the inference based solution you mentioned. |
Totally, good point. One thing that I was hoping was that we would have parity between the way workspaces declare "from" and the way results declare "from". But I think I'd totally be ok on a first pass with the validation enforcing that the user has to add the runAfters. |
Although now that I think about it a bit more - inferring the order of the tasks based on From is possibly the easy part of this issue :) See the few lines it takes for workspaces here: Here we just walk over the workspaces and add them to the Task's list of dependencies. The DAG library takes care of figuring out the rest like deciding if there're cycles or any other issues. |
@sbwsg is this something you plan on working on yourself, or does it need a volunteer? |
I have a call set up with @eddie4941 and @othomann to talk through the proposal. I'll update this issue once we've had that. |
Update after chatting with @skaegi a bit about "from" syntax / variable interpolation :- At the moment we're putting a hold on the idea of using "from" to dictate ordering in workspaces. Therefore reaching "parity" between workspaces and params on this feature is less of a priority. So we figure it's probably easiest to just jump straight to introducing variable interpolation between results and params.
Here's a short example YAML of what we want to support as a result of completing this issue: kind: Pipeline
metadata:
name: my-pipeline
spec:
tasks:
- name: task-a
taskRef:
name: foo # foo task declares a result named "sha"
- name: task-b
taskRef:
name: bar # bar task declares a param named "in-sha"
params:
- name: in-sha
value: $(tasks.task-a.results.sha) # NOTE: using variable to reference result
---
kind: Task
metadata:
name: foo
spec:
steps:
# ... omitting for brevity
results:
- name: sha
description: The SHA that this task generates
---
kind: Task
metadata:
name: bar
spec:
steps:
# ... omitting for brevity
params:
- name: in-sha |
Whoops, wrong issue to post this to! |
Is there any consideration to add It'd be nice to make this explicit so UIs or other tooling can be built easily. |
Yup this is definitely still open for debate! If there were clear reasons to support it I'd be open to implementing it in future.
Just to clarify here - the variable interpolation syntax isn't explicit enough for these use cases? Is the issue that it requires parsing a string to capture the dependencies? |
Right, it requires some parsing to capture the dependencies. Though thinking about it more, I guess |
Fixed in #2042 |
Expected Behavior
A user should be able to author a pipeline and link the results from one task into the params of another. In the short term my suggestion here is to implement this using "from" syntax that is similar to how pipeline resources and workspaces refer to one another. In the slightly longer term I suggest variable interpolation as a syntax sugar. Here's how a complete pipeline + task yaml might look with the "from" syntax (modified from an example YAML that @skaegi put together here)
The key part here is the "from" clause in
second-add
'sfirst
param. With this clause the user expresses that the value for the param should come fromfirst-add
'ssum
result.A key point for implementers here is that by expressing this relationship with a "from" clause Tekton should infer that it needs to run the
first-add
task before it runs thesecond-add
task. Again this is similar to the way the "from" clause works with pipeline resources and workspaces. Were we to go the route of using variable interpolation for this feature then we would likewise need to infer the ordering based on the variables used.Actual Behavior
Right now it's not possible to use a task result as the value for a subsequent task's param.
The text was updated successfully, but these errors were encountered: