hey , do you know how to set custom outputs in an...
# 🤖|ask-kapa
q
hey @microscopic-river-74022 , do you know how to set custom outputs in an action? Lets say I have Run.exec that executes some logic and I want set some variables to be available for next Action in the line
m
Please stand by @quaint-printer-97061 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- In Garden, you can use the concept of runtime outputs to pass information between actions. These are exposed through template keys prefixed with
actions.<kind>.<name>.outputs.
. They are resolved later than other template strings, which means you cannot use them for some fields, such as most identifiers, because those need to be resolved before validating the configuration. Here's an example of how you can pass log outputs from one task to another:
Copy code
yaml
kind: Run
type: exec
name: prep-run
spec:
  command: [echo, "my run output"]
---
kind: Deploy
name: my-deploy
dependencies: [run.prep-run]
spec:
  env:
    PREP_TASK_OUTPUT: ${actions.run.prep-run.outputs.log}  # <- resolves to "my task output"
In this example, the output from
prep-run
is copied to an environment variable for
my-deploy
. Note that you currently need to explicitly declare
prep-run
as a dependency for this to work. Different action types expose different outputs. For
exec
action, you can use the following keys: - `${actions.run..name}`: The name of the action. - `${actions.run..disabled}`: Whether the action is disabled. - `${actions.run..buildPath}`: The local path to the action build directory. - `${actions.run..sourcePath}`: The local path to the action source directory. - `${actions.run..mode}`: The mode that the action should be executed in. - `${actions.run..var.*}`: The variables configured on the action. - `${actions.run..outputs.log}`: The full log output from the executed command. For more details, please refer to the Garden documentation (). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
q
@microscopic-river-74022 That is not custom outputs but a built-in, I want to do something like
Copy code
kind: Run
type: exec
name: dependency-update
varfiles:
  - dependencies.yaml
spec:
  command: []
outputs:
  $forEach: ${variables.dependencies}
  $return:
    - name: "dependencies.${item.value.name}"
      value: "${item.value.name}-${item.value.version}.tgz"
But
outputs
is not a valid key Then, in the next Action I want to consume that as something like
${action.run.dependency-update.outputs.*}
m
Let me check the knowledge base for you. One moment! :books:
---------------------- I'm sorry for the confusion, but based on the provided knowledge sources, Garden does not currently support defining custom outputs in the
Run
action spec. The
outputs
key is not a valid key in the
Run
action spec. The
outputs
key is used in the project configuration to define project outputs that can be resolved and retrieved using the
garden get outputs
command. Here's an example:
Copy code
yaml
apiVersion: garden.io/v1
kind: Project
name: my-project
...
outputs:
  my-action-image: ${actions.build.my-image.outputs.deployment-image-id}
In this example,
my-action-image
is a project output that can be retrieved with the
garden get outputs
command. However, this does not allow you to define custom outputs in a
Run
action that can be consumed in a subsequent action. The available outputs for a
Run
action are predefined and include the full log output from the executed command (
${actions.run.<name>.outputs.log}
), among others. For more details, please refer to the Garden documentation (). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
2 Views