diff --git a/pipeline/backend/local/clone.go b/pipeline/backend/local/clone.go index 72f0d01af..8ec0bfcf1 100644 --- a/pipeline/backend/local/clone.go +++ b/pipeline/backend/local/clone.go @@ -130,12 +130,7 @@ func writeNetRC(step *types.Step, state *workflowState) (string, error) { } log.Trace().Msgf("try to write netrc to '%s'", file) - return rmCmd, os.WriteFile(file, []byte(fmt.Sprintf( - netrcFile, - step.Environment["CI_NETRC_MACHINE"], - step.Environment["CI_NETRC_USERNAME"], - step.Environment["CI_NETRC_PASSWORD"], - )), 0o600) + return rmCmd, os.WriteFile(file, []byte(genNetRC(step.Environment)), 0o600) } // downloadLatestGitPluginBinary download the latest plugin-git binary based on runtime OS and Arch diff --git a/pipeline/backend/local/const.go b/pipeline/backend/local/const.go index cc4817309..702d17b28 100644 --- a/pipeline/backend/local/const.go +++ b/pipeline/backend/local/const.go @@ -14,7 +14,10 @@ package local -import "errors" +import ( + "errors" + "fmt" +) // notAllowedEnvVarOverwrites are all env vars that can not be overwritten by step config var notAllowedEnvVarOverwrites = []string{ @@ -36,3 +39,12 @@ machine %s login %s password %s ` + +func genNetRC(env map[string]string) string { + return fmt.Sprintf( + netrcFile, + env["CI_NETRC_MACHINE"], + env["CI_NETRC_USERNAME"], + env["CI_NETRC_PASSWORD"], + ) +} diff --git a/pipeline/backend/local/local.go b/pipeline/backend/local/local.go index 998405711..80b25f59f 100644 --- a/pipeline/backend/local/local.go +++ b/pipeline/backend/local/local.go @@ -114,6 +114,7 @@ func (e *local) StartStep(ctx context.Context, step *types.Step, taskUUID string // Set HOME env = append(env, "HOME="+state.homeDir) + env = append(env, "USERPROFILE="+state.homeDir) switch step.Type { case types.StepTypeClone: