Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique status for matrix #2695

Merged
merged 12 commits into from
Nov 1, 2023
2 changes: 1 addition & 1 deletion cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ var flags = append([]cli.Flag{
EnvVars: []string{"WOODPECKER_STATUS_CONTEXT_FORMAT"},
Name: "status-context-format",
Usage: "status context format",
Value: "{{ .context }}/{{ .event }}/{{ .workflow }}",
Value: "{{ .context }}/{{ .event }}/{{ .workflow }}{{if not (eq .axis_id 0}}/{{.axis_id}}{{end}}",
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_MIGRATIONS_ALLOW_LONG"},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-administration/10-server-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ Context prefix Woodpecker will use to publish status messages to SCM. You probab

### `WOODPECKER_STATUS_CONTEXT_FORMAT`

> Default: `{{ .context }}/{{ .event }}/{{ .workflow }}`
> Default: `{{ .context }}/{{ .event }}/{{ .workflow }}{{if not (eq .axis_id 0}}/{{.axis_id}}{{end}}`

Template for the status messages published to forges, uses [Go templates](https://pkg.go.dev/text/template) as template language.
Supported variables:
Expand Down
3 changes: 2 additions & 1 deletion pipeline/stepBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ func (b *StepBuilder) Build() ([]*Item, error) {
axes = append(axes, matrix.Axis{})
}

for _, axis := range axes {
for i, axis := range axes {
workflow := &model.Workflow{
PID: pidSequence,
State: model.StatusPending,
Environ: axis,
Name: SanitizePath(y.Name),
AxisID: i + 1,
}
item, err := b.genItemForWorkflow(workflow, axis, string(y.Data))
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions server/forge/common/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"fmt"
"text/template"

"github.com/rs/zerolog/log"

"github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/model"
)
Expand All @@ -41,8 +43,10 @@
"workflow": workflow.Name,
"owner": repo.Owner,
"repo": repo.Name,
"axis_id": workflow.AxisID,
})
if err != nil {
log.Error().Err(err).Msg("could not create status context")

Check warning on line 49 in server/forge/common/status.go

View check run for this annotation

Codecov / codecov/patch

server/forge/common/status.go#L49

Added line #L49 was not covered by tests
return ""
}

Expand Down
1 change: 1 addition & 0 deletions server/model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Workflow struct {
AgentID int64 `json:"agent_id,omitempty" xorm:"workflow_agent_id"`
Platform string `json:"platform,omitempty" xorm:"workflow_platform"`
Environ map[string]string `json:"environ,omitempty" xorm:"json 'workflow_environ'"`
AxisID int `json:"-" xorm:"workflow_axis_id"`
Children []*Step `json:"children,omitempty" xorm:"-"`
}

Expand Down
Loading