mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
make it possible to disable the isolated home for local agents (#6251)
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@@ -124,6 +124,11 @@ func (e *local) writeNetRC(step *types.Step, state *workflowState) (string, erro
|
||||
return "", nil
|
||||
}
|
||||
|
||||
if !e.isolatedHome {
|
||||
log.Trace().Msg("writing .netrc skipped due to disabled isolated home")
|
||||
return "", nil
|
||||
}
|
||||
|
||||
file := filepath.Join(state.homeDir, ".netrc")
|
||||
rmCmd := fmt.Sprintf("rm \"%s\"", file)
|
||||
if e.os == "windows" {
|
||||
|
||||
@@ -28,4 +28,10 @@ var Flags = []cli.Flag{
|
||||
DefaultText: "system temporary directory",
|
||||
Value: os.TempDir(),
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Sources: cli.EnvVars("WOODPECKER_BACKEND_LOCAL_ISOLATED_HOME"),
|
||||
Name: "backend-local-isolated-home",
|
||||
Usage: "set HOME, USERPROFILE and other variables to an isolated directory, if false we ignore netrc",
|
||||
Value: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ type stepState struct {
|
||||
|
||||
type local struct {
|
||||
tempDir string
|
||||
isolatedHome bool
|
||||
workflows sync.Map
|
||||
pluginGitBinary string
|
||||
os, arch string
|
||||
@@ -84,6 +85,7 @@ func (e *local) Load(ctx context.Context) (*types.BackendInfo, error) {
|
||||
c, ok := ctx.Value(types.CliCommand).(*cli.Command)
|
||||
if ok {
|
||||
e.tempDir = c.String("backend-local-temp-dir")
|
||||
e.isolatedHome = c.Bool("backend-local-isolated-home")
|
||||
}
|
||||
|
||||
e.loadClone()
|
||||
@@ -154,9 +156,11 @@ func (e *local) StartStep(ctx context.Context, step *types.Step, taskUUID string
|
||||
}
|
||||
}
|
||||
|
||||
// Set HOME and CI_WORKSPACE
|
||||
env = append(env, "HOME="+state.homeDir)
|
||||
env = append(env, "USERPROFILE="+state.homeDir)
|
||||
if e.isolatedHome {
|
||||
env = append(env, "HOME="+state.homeDir)
|
||||
env = append(env, "USERPROFILE="+state.homeDir)
|
||||
}
|
||||
|
||||
env = append(env, "CI_WORKSPACE="+state.workspaceDir)
|
||||
|
||||
switch step.Type {
|
||||
|
||||
@@ -190,6 +190,7 @@ func TestRunStep(t *testing.T) {
|
||||
|
||||
backend, _ := New().(*local)
|
||||
backend.tempDir = t.TempDir()
|
||||
backend.isolatedHome = true
|
||||
ctx := t.Context()
|
||||
taskUUID := "test-run-tasks"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user