mirror of
https://github.com/go-task/task.git
synced 2026-06-15 11:51:41 +00:00
#324 implement dotenv
This commit is contained in:
@@ -33,8 +33,10 @@ executable called must be available by the OS or in PATH.
|
||||
|
||||
If you omit a task name, "default" will be assumed.
|
||||
|
||||
## Environment
|
||||
## Environment variables
|
||||
|
||||
|
||||
### Task
|
||||
You can use `env` to set custom environment variables for a specific task:
|
||||
|
||||
```yaml
|
||||
@@ -66,6 +68,39 @@ tasks:
|
||||
> NOTE: `env` supports expansion and retrieving output from a shell command
|
||||
> just like variables, as you can see on the [Variables](#variables) section.
|
||||
|
||||
|
||||
### Operating System
|
||||
Environment variables from the OS are accessible using `$VARNAME`:
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Hello $USER"
|
||||
```
|
||||
|
||||
### .env
|
||||
|
||||
*.env* files are supported in v3 using the `dotenv` declaration:
|
||||
|
||||
.env
|
||||
```
|
||||
KEYNAME=VALUE
|
||||
```
|
||||
Taskfile.yml
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
dotenv: ['.env']
|
||||
|
||||
tasks:
|
||||
greet:
|
||||
cmds:
|
||||
- echo "Using $KEYNAME"
|
||||
```
|
||||
|
||||
## Operating System specific tasks
|
||||
|
||||
If you add a `Taskfile_{{GOOS}}.yml` you can override or amend your Taskfile
|
||||
|
||||
Reference in New Issue
Block a user