mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-03 04:33:48 +00:00
Add option to set the local repository path to the cli command exec. (#3524)
The cli command exec not handle in a coherent way the repository path when a directory or filename is given for the pipeline. ` woodpecker-cli exec [command options] [path/to/.woodpecker.yaml]` If the path to the pipeline is a file in the `.woodpecker` directory, for example: `.woodpecker/pipeline.yaml`, the repository path will be: `.woodpecker` If the path to the pipeline yaml is a directory with more than one level, for example `ci/woodpecker/`, the repository path will be: `ci` In order not to break the old behavior we added a new option to put the root directory of the repository: ~~~ woodpecker-cli exec --local --repo-path . --pipeline-event manual .woodpecker/build.yml ~~~
This commit is contained in:
parent
5a2a4bd53c
commit
9c684b7a22
3 changed files with 19 additions and 2 deletions
|
@ -57,7 +57,12 @@ func run(c *cli.Context) error {
|
||||||
|
|
||||||
func execDir(c *cli.Context, dir string) error {
|
func execDir(c *cli.Context, dir string) error {
|
||||||
// TODO: respect pipeline dependency
|
// 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" {
|
if runtime.GOOS == "windows" {
|
||||||
repoPath = convertPathForWindows(repoPath)
|
repoPath = convertPathForWindows(repoPath)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +84,12 @@ func execDir(c *cli.Context, dir string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func execFile(c *cli.Context, file 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" {
|
if runtime.GOOS == "windows" {
|
||||||
repoPath = convertPathForWindows(repoPath)
|
repoPath = convertPathForWindows(repoPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,11 @@ var flags = []cli.Flag{
|
||||||
Usage: "run from local directory",
|
Usage: "run from local directory",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
EnvVars: []string{"WOODPECKER_REPO_PATH"},
|
||||||
|
Name: "repo-path",
|
||||||
|
Usage: "path to local repository",
|
||||||
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_TIMEOUT"},
|
EnvVars: []string{"WOODPECKER_TIMEOUT"},
|
||||||
Name: "timeout",
|
Name: "timeout",
|
||||||
|
|
|
@ -280,6 +280,8 @@ execute a local pipeline
|
||||||
|
|
||||||
**--repo-clone-url**="":
|
**--repo-clone-url**="":
|
||||||
|
|
||||||
|
**--repo-path**="": path to local repository
|
||||||
|
|
||||||
**--repo-private**="":
|
**--repo-private**="":
|
||||||
|
|
||||||
**--repo-remote-id**="":
|
**--repo-remote-id**="":
|
||||||
|
|
Loading…
Reference in a new issue