diff --git a/.gitignore b/.gitignore index d713321..59d93df 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ _testmain.go vendor drone-jenkins coverage.txt +.env diff --git a/README.md b/README.md index 5452a97..9a83f02 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,13 @@ docker run --rm \ -w $(pwd) \ appleboy/drone-jenkins ``` + +Load all environments from file. + +```bash +docker run --rm \ + -e ENV_FILE=your_env_file_path \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + appleboy/drone-jenkins +``` diff --git a/main.go b/main.go index 9327a7b..0290347 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "os" + "github.com/joho/godotenv" _ "github.com/joho/godotenv/autoload" "github.com/urfave/cli" ) @@ -90,11 +91,20 @@ func main() { Usage: "build link", EnvVar: "DRONE_BUILD_LINK", }, + cli.StringFlag{ + Name: "env-file", + Usage: "source env file", + EnvVar: "ENV_FILE", + }, } app.Run(os.Args) } func run(c *cli.Context) error { + if c.String("env-file") != "" { + _ = godotenv.Load(c.String("env-file")) + } + plugin := Plugin{ Repo: Repo{ Owner: c.String("repo.owner"),