Allow task output to be the value of a dynamic varible #2143
Replies: 3 comments 1 reply
-
If I understand correctly, you can obtain what you are looking for with YAML anchors (https://smcleod.net/2022/11/yaml-anchors-and-aliases/). It is ugly but it works:
and:
|
Beta Was this translation helpful? Give feedback.
-
The same idea has already been described in #1439. And I think this would be a really useful functionality. (+1 for this) A short and simple use case that I would like to have: # ...
prettier:
label: 'Prettier'
desc: 'Runs `prettier` command.'
cmd: '{{.NODEJS_BIN_DIR}}/prettier {{.CLI_ARGS}}'
silent: true
# ...
lint:prettier:
label: 'Prettier'
desc: 'Checks for common format issues with prettier.'
cmds:
- cmd: 'echo Prettier {{.PRETTIER_VERSION}}'
vars:
PRETTIER_VERSION:
task: prettier
vars: { CLI_ARGS: '-v' }
- task: prettier
vars: { CLI_ARGS: '. -c' }
# ... |
Beta Was this translation helpful? Give feedback.
-
You can of course either; redirect your docker command output to a file, and then load that with a sh command into a variable; or run task directly via the sh command, capturing the output to a variable. Running tasks and capturing output would seem possible. Here you can see how the task executor makes it possible to capture stdout/err ... that might be the easy part ... otherwise it seems similar to the 'defer' (in terms of schema), and could also be applied to 'preconditions'. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Today the following is supported
I would like the following to work too
(please don't read too much into the example, I just took the example from the docs and modified it to highlight the use case.
My actual use case is easily capturing the output from tasks to send in notifications.
In particular I have a templated
docker:run
that looks like:and in my main taskfile
Instead I have to use
Which while it works it breaks out of this little DSL I have for working with docker and it also makes
--dry
less useful since it tries to actually execute the sh command.Thank you for your consideration!
Beta Was this translation helpful? Give feedback.
All reactions