Merge pull request #2 from appleboy/cli

Support load configuration from files.
This commit is contained in:
Bo-Yi Wu
2016-11-21 11:19:12 +08:00
committed by GitHub
3 changed files with 21 additions and 0 deletions
+1
View File
@@ -25,3 +25,4 @@ _testmain.go
vendor
drone-jenkins
coverage.txt
.env
+10
View File
@@ -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
```
+10
View File
@@ -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"),