Skip to content

Commit

Permalink
local backend set home variable windows-equivalent too (#2323)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored Oct 1, 2023
1 parent dd335f4 commit 8629a41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
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

0 comments on commit 8629a41

Please sign in to comment.