mirror of
https://github.com/appleboy/drone-jenkins.git
synced 2026-06-04 10:15:02 +08:00
chore: load env from /run/drone/env path
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -13,6 +12,15 @@ import (
|
||||
var Version string
|
||||
|
||||
func main() {
|
||||
// Load env-file if it exists first
|
||||
if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found {
|
||||
godotenv.Load(filename)
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||
godotenv.Overload("/run/drone/env")
|
||||
}
|
||||
|
||||
app := cli.NewApp()
|
||||
app.Name = "jenkins plugin"
|
||||
app.Usage = "trigger jenkins jobs"
|
||||
@@ -46,12 +54,6 @@ func main() {
|
||||
Usage: "jenkins job",
|
||||
EnvVar: "PLUGIN_JOB,JENKINS_JOB,INPUT_JOB",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "env-file",
|
||||
Usage: "source env file",
|
||||
EnvVar: "ENV_FILE",
|
||||
Value: ".env",
|
||||
},
|
||||
}
|
||||
|
||||
// Override a template
|
||||
@@ -93,10 +95,6 @@ REPOSITORY:
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
if c.String("env-file") != "" {
|
||||
_ = godotenv.Load(c.String("env-file"))
|
||||
}
|
||||
|
||||
plugin := Plugin{
|
||||
BaseURL: c.String("host"),
|
||||
Username: c.String("user"),
|
||||
|
||||
Reference in New Issue
Block a user