Skip to content

Commit

Permalink
Fix upload to jfrog for windows (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham149 authored Apr 5, 2022
1 parent f6266e2 commit f00a998
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ func Exec(ctx context.Context, args Args) error {
}

// Set authentication params
envPrefix := getEnvPrefix()
if args.Username != "" && args.Password != "" {
cmdArgs = append(cmdArgs, "--user $PLUGIN_USERNAME")
cmdArgs = append(cmdArgs, "--password $PLUGIN_PASSWORD")
cmdArgs = append(cmdArgs, fmt.Sprintf("--user %sPLUGIN_USERNAME", envPrefix))
cmdArgs = append(cmdArgs, fmt.Sprintf("--password %sPLUGIN_PASSWORD", envPrefix))
} else if args.APIKey != "" {
cmdArgs = append(cmdArgs, "--apikey $PLUGIN_API_KEY")
cmdArgs = append(cmdArgs, fmt.Sprintf("--apikey %sPLUGIN_API_KEY", envPrefix))
} else if args.AccessToken != "" {
cmdArgs = append(cmdArgs, "--access-token $PLUGIN_ACCESS_TOKEN")
cmdArgs = append(cmdArgs, fmt.Sprintf("--access-token %sPLUGIN_ACCESS_TOKEN", envPrefix))
} else {
return fmt.Errorf("either username/password, api key or access token needs to be set")
}
Expand Down Expand Up @@ -93,6 +94,13 @@ func getJfrogBin() string {
return "jfrog"
}

func getEnvPrefix() string {
if runtime.GOOS == "windows" {
return "$Env:"
}
return "$"
}

// trace writes each command to stdout with the command wrapped in an xml
// tag so that it can be extracted and displayed in the logs.
func trace(cmd *exec.Cmd) {
Expand Down

0 comments on commit f00a998

Please sign in to comment.