| --- | |
| title: 'Action' | |
| --- | |
| An action created during rule analysis. | |
| This object is visible for the purpose of testing, and may be obtained from an `Actions` provider. It is normally not necessary to access `Action` objects or their fields within a rule's implementation function. You may instead want to see the [Rules page](https://bazel.build/versions/9.3.0/extending/rules#actions) for a general discussion of how to use actions when defining custom rules, or the [API reference](../builtins/actions) for creating actions. | |
| Some fields of this object are only applicable for certain kinds of actions. Fields that are inapplicable are set to `None`. | |
| ## Members | |
| * [args](#args) | |
| * [argv](#argv) | |
| * [content](#content) | |
| * [env](#env) | |
| * [inputs](#inputs) | |
| * [mnemonic](#mnemonic) | |
| * [outputs](#outputs) | |
| * [substitutions](#substitutions) | |
| ## args {#args} | |
| ``` | |
| sequence Action.args | |
| ``` | |
| A list of frozen [Args](../builtins/Args) objects containing information about the action arguments. These objects contain accurate argument information, including arguments involving expanded action output directories. However, [Args](../builtins/Args) objects are not readable in the analysis phase. For a less accurate account of arguments which is available in the analysis phase, see [argv](#argv). | |
| Note that some types of actions do not yet support exposure of this field. For such action types, this is `None`. | |
| May return `None`. | |
| ## argv {#argv} | |
| ``` | |
| sequence Action.argv | |
| ``` | |
| For actions created by [ctx.actions.run()](../builtins/actions#run) or [ctx.actions.run_shell()](../builtins/actions#run_shell) an immutable list of the arguments for the command line to be executed. Note that for shell actions the first two arguments will be the shell path and `"-c"`. | |
| May return `None`. | |
| ## content {#content} | |
| ``` | |
| string Action.content | |
| ``` | |
| For actions created by [ctx.actions.write()](../builtins/actions#write) or [ctx.actions.expand_template()](../builtins/actions#expand_template), the contents of the file to be written, if those contents can be computed during the analysis phase. The value is `None` if the contents cannot be determined until the execution phase, such as when a directory in an [Args](../builtins/Args) object needs to be expanded. | |
| May return `None`. | |
| ## env {#env} | |
| ``` | |
| dict Action.env | |
| ``` | |
| The 'fixed' environment variables for this action. This includes only environment settings which are explicitly set by the action definition, and thus omits settings which are only pre-set in the execution environment. | |
| ## inputs {#inputs} | |
| ``` | |
| depset Action.inputs | |
| ``` | |
| A set of the input files of this action. | |
| ## mnemonic {#mnemonic} | |
| ``` | |
| string Action.mnemonic | |
| ``` | |
| The mnemonic for this action. | |
| ## outputs {#outputs} | |
| ``` | |
| depset Action.outputs | |
| ``` | |
| A set of the output files of this action. | |
| ## substitutions {#substitutions} | |
| ``` | |
| dict Action.substitutions | |
| ``` | |
| For actions created by [ctx.actions.expand_template()](../builtins/actions#expand_template), an immutable dict holding the substitution mapping. | |
| May return `None`. |