-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to trigger manual builds (#1156)
closes #83 closes #240 Co-authored-by: Anbraten <anton@ju60.de> Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
- Loading branch information
1 parent
86bc751
commit b4d89a1
Showing
33 changed files
with
1,117 additions
and
827 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ var Command = &cli.Command{ | |
buildQueueCmd, | ||
buildKillCmd, | ||
buildPsCmd, | ||
buildCreateCmd, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package build | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||
|
||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/woodpecker-ci/woodpecker/cli/common" | ||
"github.com/woodpecker-ci/woodpecker/cli/internal" | ||
) | ||
|
||
var buildCreateCmd = &cli.Command{ | ||
Name: "create", | ||
Usage: "create new build", | ||
ArgsUsage: "<repo/name>", | ||
Action: buildCreate, | ||
Flags: append(common.GlobalFlags, | ||
common.FormatFlag(tmplBuildList), | ||
&cli.StringFlag{ | ||
Name: "branch", | ||
Usage: "branch to create build from", | ||
Required: true, | ||
}, | ||
&cli.StringSliceFlag{ | ||
Name: "var", | ||
Usage: "key=value", | ||
}, | ||
), | ||
} | ||
|
||
func buildCreate(c *cli.Context) error { | ||
repo := c.Args().First() | ||
|
||
owner, name, err := internal.ParseRepo(repo) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
client, err := internal.NewClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
branch := c.String("branch") | ||
variables := make(map[string]string) | ||
|
||
for _, vaz := range c.StringSlice("var") { | ||
sp := strings.SplitN(vaz, "=", 2) | ||
if len(sp) == 2 { | ||
variables[sp[0]] = sp[1] | ||
} | ||
} | ||
|
||
options := &woodpecker.BuildOptions{ | ||
Branch: branch, | ||
Variables: variables, | ||
} | ||
|
||
build, err := client.BuildCreate(owner, name, options) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tmpl, err := template.New("_").Parse(c.String("format") + "\n") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := tmpl.Execute(os.Stdout, build); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.