How do I set exec build output variables so they c...
# 🤖|ask-kapa
w
@microscopic-river-74022 How do I set exec build output variables so they can be used in a deploy action?
m
Please stand by @white-kite-45517 as I search the knowledge base. I normally take about 15 seconds or so. :wave:
---------------------- To set exec build output variables that can be used in a deploy action, you can utilize the runtime outputs feature in Garden. Here's how you can do it: 1. In your exec build action, you can output information that you want to use later by echoing it to stdout or stderr. 2. These outputs are then available via template strings in other actions that depend on the build action. 3. Specifically, you can access the following outputs from an exec build action: - `${actions.build..outputs.log}`: The full log output - `${actions.build..outputs.stdout}`: The stdout log output - `${actions.build..outputs.stderr}`: The stderr log output 4. In your deploy action, you can then use these outputs by referencing them in the configuration. Here's an example of how this might look:
Copy code
yaml
kind: Build
type: exec
name: my-build
spec:
  command: [echo, "my build output"]

---

kind: Deploy
name: my-deploy
dependencies: [build.my-build]
spec:
  env:
    BUILD_OUTPUT: ${actions.build.my-build.outputs.log}
In this example, the output from the build action is made available as an environment variable in the deploy action. It's important to note that you need to explicitly declare the build action as a dependency for the deploy action for this to work. For more detailed information, you can refer to the [Action Runtime outputs]() section in the Garden documentation. [Reference > Action-types > Build > exec Build > Outputs]() Remember, it's a good practice to make your build outputs machine-readable so they can be easily parsed by dependent actions. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
w
How do I send output from the exec command to a custom variable
How do I send output from the exec command to a custom variable?
@microscopic-river-74022 How do I send output from the exec command to a custom variable?
m
Let me check the knowledge base for you again. One moment! :books:
---------------------- To send output from an exec command to a custom variable in Garden, you can use the
outputs
feature of the exec action. Here's how you can do it: 1. In your exec action (which could be a Build, Run, Test, or Deploy action), you can capture the command output. 2. The output is automatically stored in predefined variables, which you can then reference in other actions or parts of your configuration. 3. The available output variables are: - `${actions...outputs.log}`: The full log output - `${actions...outputs.stdout}`: The stdout log output - `${actions...outputs.stderr}`: The stderr log output Here's an example of how you might use this in a configuration:
Copy code
yaml
kind: Run
type: exec
name: my-run
spec:
  command: [echo, "Hello, Garden!"]
---
kind: Deploy
name: my-deploy
dependencies: [run.my-run]
spec:
  env:
    MY_CUSTOM_VAR: ${actions.run.my-run.outputs.stdout}
In this example, the output from the
my-run
action is captured in the
MY_CUSTOM_VAR
environment variable of the
my-deploy
action. It's important to note a few things: 1. You need to explicitly declare the action that produces the output as a dependency. 2. These output variables are resolved later than other template strings, so they can't be used for fields that need to be resolved early, such as most identifiers. 3. It's a good practice to make your command outputs machine-readable for easy parsing by dependent actions. For more detailed information, you can refer to the [Action Runtime outputs]() section in the Garden documentation. [Reference > Action-types > Run > exec Run > Outputs]()
Remember, this approach works for all exec action types (Build, Run, Test, Deploy), so you can use the same pattern regardless of the specific action type you're working with. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
3 Views