sake icon indicating copy to clipboard operation
sake copied to clipboard

How can a task pass a value to next task

Open MushiTheMoshi opened this issue 3 years ago • 1 comments

Hi there,

I am testing the tool, I like the simplicity very useful. Thank you.

I want to know if there is a way to store output from a task to use in the next task in the same recipe?

Hope you can help me.

Regards, Julio

MushiTheMoshi avatar Aug 04 '22 23:08 MushiTheMoshi

Hi, currently it's not possible but it's on the TODO list https://github.com/alajmo/sake/issues/16

alajmo avatar Aug 06 '22 19:08 alajmo

If it's a non-secret value, could you echo it to a /tmp file at the end of task 1 and then cat that file into a variable at the start of task 2?

itmecho avatar Oct 08 '22 15:10 itmecho

Well it's possible to do something like this:

tasks:
  pass-env:
    tasks:
      - cmd: echo hello > /tmp/some-env
      - cmd: cat /tmp/some-env
$ sake run pass-env

 Server   | Output | Output
----------+--------+--------
 server-1 |        | hello

But it's not pretty and I'm looking into something more user-friendly. With this solution, you would need to clear the tmp file after each run manually (so as not to have a stale state).

alajmo avatar Oct 09 '22 10:10 alajmo

thanks! that was my first guess I was thinking more for having conditional tasks, this is also working.

MushiTheMoshi avatar Oct 09 '22 12:10 MushiTheMoshi