diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 6a98de7..c5801eb 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -166,9 +166,9 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. } runnerConfig := &runner.Config{ - // On Linux, Workdir will be like "//" - // On Windows, Workdir will be like "\\" - Workdir: filepath.FromSlash(string(filepath.Separator) + preset.Repository), + // On Linux, Workdir will be like "///" + // On Windows, Workdir will be like "\\\" + Workdir: filepath.FromSlash(fmt.Sprintf("/%s/%s", r.cfg.Container.WorkdirParent, preset.Repository)), BindWorkdir: false, ReuseContainers: false, diff --git a/internal/pkg/config/config.example.yaml b/internal/pkg/config/config.example.yaml index 12e69f8..a3cc4b3 100644 --- a/internal/pkg/config/config.example.yaml +++ b/internal/pkg/config/config.example.yaml @@ -48,3 +48,6 @@ container: privileged: false # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). options: + # The parent directory of a job's working directory. + # If it's empty, /workspace will be used. + workdir_parent: diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index 30e33d2..7cbcfc2 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -34,9 +34,10 @@ type Config struct { Port uint16 `yaml:"port"` } `yaml:"cache"` Container struct { - NetworkMode string `yaml:"network_mode"` - Privileged bool `yaml:"privileged"` - Options string `yaml:"options"` + NetworkMode string `yaml:"network_mode"` + Privileged bool `yaml:"privileged"` + Options string `yaml:"options"` + WorkdirParent string `yaml:"workdir_parent"` } `yaml:"container"` } @@ -94,6 +95,9 @@ func LoadDefault(file string) (*Config, error) { if cfg.Container.NetworkMode == "" { cfg.Container.NetworkMode = "bridge" } + if cfg.Container.WorkdirParent == "" { + cfg.Container.WorkdirParent = "workspace" + } if cfg.Runner.FetchTimeout <= 0 { cfg.Runner.FetchTimeout = 5 * time.Second }