Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set home variable in local backend for windows #2323

Merged
merged 5 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions pipeline/backend/local/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion pipeline/backend/local/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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"],
)
}
1 change: 1 addition & 0 deletions pipeline/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down