tooploox / oya

Using Oya packs containing reusable boilerplate & scripts, you can bootstrap easy to work with, deployable projects
https://oya.sh
MIT License
151 stars 3 forks source link

Implement result/output passing for tasks #60

Closed moritzheiber closed 4 years ago

moritzheiber commented 5 years ago

I'd love to be able run a certain task and pass its output result (could be stdout or stderr) into a value/variable I can then use with another task, either as a regular environment variable or as a template value (i.e. Oya[my_value]).

It would make it easier to orchestration depended workflows.

bart84ek commented 5 years ago

Thanks @moritzheiber for looking into it. We know there is a gap with fetching output from tasks. One way to do is to assign value in bash (stdout), and then even pass them to oya render with --set parameter. We know it's not very convenient.

subTask: |
  echo "Foo"

task: |
  val=`oya run subTask`
  echo "output from subtask"
  echo $val

Thanks for your issue. We will think how to improve it

bilus commented 5 years ago

@moritzheiber I fixed @bart84ek's code (he's on vacation atm:).

To add to his point, you can also pass arguments to tasks so:

subTask: |
  echo "Foo"

task: |
  val=`oya run subTask`
  echo "output from subtask"
  oya run anotherTask $val

anotherTask: |
  echo All arguments: $@
  echo First argument: $1

I hope it's good enough for what you need.