1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-05-22 08:55:42 +02:00

Add env for workflow and step name (#1693)

closes #1681
This commit is contained in:
Anbraten
2023-04-08 13:15:28 +02:00
committed by GitHub
parent 6af9371011
commit 36b5ae3459
9 changed files with 80 additions and 50 deletions
+9 -4
View File
@@ -112,7 +112,7 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error
metadata := metadataFromContext(c, axis)
environ := metadata.Environ()
var secrets []compiler.Secret
for key, val := range metadata.Step.Matrix {
for key, val := range metadata.Workflow.Matrix {
environ[key] = val
secrets = append(secrets, compiler.Secret{
Name: key,
@@ -218,7 +218,7 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error
ctx, cancel := context.WithTimeout(context.Background(), c.Duration("timeout"))
defer cancel()
ctx = utils.WithContextSigtermCallback(ctx, func() {
println("ctrl+c received, terminating process")
fmt.Println("ctrl+c received, terminating process")
})
return pipeline.New(compiled,
@@ -290,10 +290,15 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) frontend.Metadata {
},
},
},
Step: frontend.Step{
Number: c.Int("step-number"),
Workflow: frontend.Workflow{
Name: c.String("workflow-name"),
Number: c.Int("workflow-number"),
Matrix: axis,
},
Step: frontend.Step{
Name: c.String("step-name"),
Number: c.Int("step-number"),
},
Sys: frontend.System{
Name: c.String("system-name"),
Link: c.String("system-link"),
+10 -2
View File
@@ -260,8 +260,16 @@ var flags = []cli.Flag{
Name: "prev-commit-author-email",
},
&cli.IntFlag{
EnvVars: []string{"CI_STEP_NUMBER", "CI_JOB_NUMBER"},
Name: "step-number",
EnvVars: []string{"CI_WORKFLOW_NAME"},
Name: "workflow-name",
},
&cli.IntFlag{
EnvVars: []string{"CI_WORKFLOW_NUMBER", "CI_JOB_NUMBER"},
Name: "workflow-number",
},
&cli.IntFlag{
EnvVars: []string{"CI_STEP_NAME", "CI_JOB_NUMBER"},
Name: "step-name",
},
&cli.StringSliceFlag{
EnvVars: []string{"CI_ENV"},