Unique status for matrix (#2695)

implement this fix but with an additional field on workflows to not
change the workflow name

closes #1840 
closes #713

---------

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
qwerty287 2023-11-01 17:28:02 +01:00 committed by GitHub
parent 037703028e
commit abb2f280eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 3 deletions

View file

@ -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"},

View file

@ -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:

View file

@ -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 {

View file

@ -19,6 +19,8 @@ import (
"fmt"
"text/template"
"github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/model"
)
@ -41,8 +43,10 @@ func GetPipelineStatusContext(repo *model.Repo, pipeline *model.Pipeline, workfl
"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")
return ""
}

View file

@ -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:"-"`
}