From efbde332a371547417c990b34255b64d3e15394e Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:54:10 +0200 Subject: [PATCH] Fix `CI_WORKSPACE` in local backend (#2627) closes https://github.com/woodpecker-ci/woodpecker/issues/2610 --- pipeline/backend/local/clone.go | 2 -- pipeline/backend/local/const.go | 1 + pipeline/backend/local/local.go | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pipeline/backend/local/clone.go b/pipeline/backend/local/clone.go index 8ec0bfcf1..5ad899548 100644 --- a/pipeline/backend/local/clone.go +++ b/pipeline/backend/local/clone.go @@ -84,8 +84,6 @@ func (e *local) execClone(ctx context.Context, step *types.Step, state *workflow return err } - env = append(env, "CI_WORKSPACE="+state.workspaceDir) - // Prepare command var cmd *exec.Cmd if rmCmd != "" { diff --git a/pipeline/backend/local/const.go b/pipeline/backend/local/const.go index 702d17b28..70594a762 100644 --- a/pipeline/backend/local/const.go +++ b/pipeline/backend/local/const.go @@ -27,6 +27,7 @@ var notAllowedEnvVarOverwrites = []string{ "CI_SCRIPT", "HOME", "SHELL", + "CI_WORKSPACE", } var ( diff --git a/pipeline/backend/local/local.go b/pipeline/backend/local/local.go index 070f1db28..37169f818 100644 --- a/pipeline/backend/local/local.go +++ b/pipeline/backend/local/local.go @@ -112,9 +112,10 @@ func (e *local) StartStep(ctx context.Context, step *types.Step, taskUUID string } } - // Set HOME + // Set HOME and CI_WORKSPACE env = append(env, "HOME="+state.homeDir) env = append(env, "USERPROFILE="+state.homeDir) + env = append(env, "CI_WORKSPACE="+state.workspaceDir) switch step.Type { case types.StepTypeClone: