drone-git-push icon indicating copy to clipboard operation
drone-git-push copied to clipboard

Plugin breaks with due to incorrect EnvVars for some flags

Open rutgerbrf opened this issue 2 years ago • 2 comments

This issue was introduced in v0.2.2. It is caused by 1aa722ba5c63bf4c5985069e478b2cf9c1ab6919, in the following code: https://github.com/appleboy/drone-git-push/blob/b90f5fdbc9b893f5b873686477112a0795d18e7a/main.go#L44-L58

Here, the EnvVars slices are not of the appropriate form. This makes the environment variables not load correctly, causing the plugin to fail in some use cases.

This patch fixed the issue for me:

diff --git a/main.go b/main.go
index cee6a2d..00bfa9e 100644
--- a/main.go
+++ b/main.go
@@ -44,17 +44,17 @@ func main() {
 		&cli.StringFlag{
 			Name:    "netrc.machine",
 			Usage:   "netrc machine",
-			EnvVars: []string{"PLUGIN_NETRC_MACHINE,DRONE_NETRC_MACHINE"},
+			EnvVars: []string{"PLUGIN_NETRC_MACHINE", "DRONE_NETRC_MACHINE"},
 		},
 		&cli.StringFlag{
 			Name:    "netrc.username",
 			Usage:   "netrc username",
-			EnvVars: []string{"PLUGIN_USERNAME,DRONE_NETRC_USERNAME,GITHUB_USERNAME"},
+			EnvVars: []string{"PLUGIN_USERNAME", "DRONE_NETRC_USERNAME", "GITHUB_USERNAME"},
 		},
 		&cli.StringFlag{
 			Name:    "netrc.password",
 			Usage:   "netrc password",
-			EnvVars: []string{"PLUGIN_PASSWORD,DRONE_NETRC_PASSWORD,GITHUB_PASSWORD"},
+			EnvVars: []string{"PLUGIN_PASSWORD", "DRONE_NETRC_PASSWORD", "GITHUB_PASSWORD"},
 		},
 		&cli.StringFlag{
 			Name:    "ssh-key",

rutgerbrf avatar Aug 03 '22 12:08 rutgerbrf

@rutgerbrf, would you mind propose a pull request with this patch to solve this issue?

gpantanetti avatar Aug 30 '22 08:08 gpantanetti

@gpantanetti, no problem. See #56.

rutgerbrf avatar Aug 30 '22 08:08 rutgerbrf