1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-01-17 17:45:03 +02:00

local backend set home variable windows-equivalent too (#2323)

This commit is contained in:
6543 2023-10-01 13:56:49 +01:00 committed by GitHub
parent dd335f43f7
commit 8629a418f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -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

View File

@ -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"],
)
}

View File

@ -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: