feat: add custom environment variable configuration to rover.json #231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for custom environment variable configuration in rover.json, enabling projects to inject additional environment variables into AI agent containers. This feature introduces two optional properties:
envs
for explicit environment variable definitions and passthroughs, andenvsFile
for loading variables from dotenv files.The custom environment variables are merged with agent-specific defaults and passed to Docker containers during task execution.
It closes #225
Changes
envs
andenvsFile
optional properties toProjectConfigSchema
with appropriate getters1.0
to1.1
to support new configuration fieldsparseCustomEnvironmentVariables()
utility function supporting both passthrough (ENV_NAME
) and explicit value (ENV_NAME=VALUE
) formatsloadEnvsFile()
utility function with path traversal validation and dotenv file parsingstartDockerExecution()
in task command to load, parse, and merge custom environment variables with agent defaultsdotenv
package as a dependency for parsing dotenv filesNotes
Custom environment variables are appended after agent defaults when passed to Docker. When the same variable appears multiple times, Docker uses the last occurrence, allowing custom variables to override agent defaults.
Path traversal protection ensures
envsFile
paths are validated to stay within the project root directory. Invalid paths and missing files are silently skipped to maintain backwards compatibility.Demo
I updated the project
rover.json
file to:Inside the container:
$ docker exec -it rover-task-74-1 bash d04ab61b998a:/workspace$ env CUSTOM_VAR=test STARSHIP_SHELL=bash ANOTHER_TEST=bye THIS_IS_A_TEST=hello ...