diff --git a/cli/exec/exec.go b/cli/exec/exec.go index 44dabe116e..b1907e6c4e 100644 --- a/cli/exec/exec.go +++ b/cli/exec/exec.go @@ -57,7 +57,12 @@ func run(c *cli.Context) error { func execDir(c *cli.Context, dir string) error { // TODO: respect pipeline dependency - repoPath, _ := filepath.Abs(filepath.Dir(dir)) + repoPath := c.String("repo-path") + if repoPath != "" { + repoPath, _ = filepath.Abs(repoPath) + } else { + repoPath, _ = filepath.Abs(filepath.Dir(dir)) + } if runtime.GOOS == "windows" { repoPath = convertPathForWindows(repoPath) } @@ -79,7 +84,12 @@ func execDir(c *cli.Context, dir string) error { } func execFile(c *cli.Context, file string) error { - repoPath, _ := filepath.Abs(filepath.Dir(file)) + repoPath := c.String("repo-path") + if repoPath != "" { + repoPath, _ = filepath.Abs(repoPath) + } else { + repoPath, _ = filepath.Abs(filepath.Dir(file)) + } if runtime.GOOS == "windows" { repoPath = convertPathForWindows(repoPath) } diff --git a/cli/exec/flags.go b/cli/exec/flags.go index be2bb69a27..dd65b6af13 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -29,6 +29,11 @@ var flags = []cli.Flag{ Usage: "run from local directory", Value: true, }, + &cli.StringFlag{ + EnvVars: []string{"WOODPECKER_REPO_PATH"}, + Name: "repo-path", + Usage: "path to local repository", + }, &cli.DurationFlag{ EnvVars: []string{"WOODPECKER_TIMEOUT"}, Name: "timeout", diff --git a/docs/versioned_docs/version-2.4/40-cli.md b/docs/versioned_docs/version-2.4/40-cli.md index 6766e9d78f..639c2ebfb4 100644 --- a/docs/versioned_docs/version-2.4/40-cli.md +++ b/docs/versioned_docs/version-2.4/40-cli.md @@ -280,6 +280,8 @@ execute a local pipeline **--repo-clone-url**="": +**--repo-path**="": path to local repository + **--repo-private**="": **--repo-remote-id**="":