mirror of
https://codeberg.org/woodpecker-plugins/go-plugin
synced 2026-06-04 10:14:59 +08:00
Support CI_STEP_NAME and CI_STEP_TYPE (#88)
needs https://github.com/woodpecker-ci/woodpecker/pull/4290 (woodpecker >= v3.15.0) Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/88 Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
@@ -22,13 +22,40 @@ import (
|
||||
|
||||
// Step defines runtime metadata for a step.
|
||||
type Step struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Type StepType `json:"type,omitempty"`
|
||||
Number int `json:"number,omitempty"`
|
||||
Started time.Time `json:"started,omitempty"`
|
||||
Finished time.Time `json:"finished,omitempty"`
|
||||
}
|
||||
|
||||
// StepType identifies the type of step.
|
||||
type StepType string
|
||||
|
||||
const (
|
||||
StepTypeClone StepType = "clone"
|
||||
StepTypeService StepType = "service"
|
||||
StepTypePlugin StepType = "plugin"
|
||||
StepTypeCommands StepType = "commands"
|
||||
StepTypeCache StepType = "cache"
|
||||
)
|
||||
|
||||
func stepFlags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "step.name",
|
||||
Usage: "step name",
|
||||
Sources: cli.EnvVars(
|
||||
"CI_STEP_NAME",
|
||||
),
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "step.type",
|
||||
Usage: "step type",
|
||||
Sources: cli.EnvVars(
|
||||
"CI_STEP_TYPE",
|
||||
),
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "step.number",
|
||||
Usage: "step number",
|
||||
@@ -56,6 +83,8 @@ func stepFlags() []cli.Flag {
|
||||
|
||||
func stepFromContext(c *cli.Command) Step {
|
||||
return Step{
|
||||
Name: c.String("step.name"),
|
||||
Type: StepType(c.String("step.type")),
|
||||
Number: c.Int("step.number"),
|
||||
Started: time.Unix(c.Int64("step.started"), 0),
|
||||
Finished: time.Unix(c.Int64("step.finished"), 0),
|
||||
|
||||
Reference in New Issue
Block a user