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

Rework pipeline messages #4626

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1cfdc6e
Do some work to refactor the pipeline model
qwerty287 Dec 27, 2024
d34e37e
continue - finish pipeline model
qwerty287 Dec 27, 2024
af7c138
Merge branch 'main' into pl-commit-pr
qwerty287 Dec 29, 2024
6d66b50
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 2, 2025
9eff475
finish forge loaders
qwerty287 Jan 2, 2025
8d66111
make author a pure commit author
qwerty287 Jan 2, 2025
79d438a
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 2, 2025
fce415f
migrate cli & web, add migration
qwerty287 Jan 3, 2025
50daca0
rename to "Labels" only
qwerty287 Jan 3, 2025
31f0961
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 4, 2025
4af5e79
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 5, 2025
c709a1d
fix feed
qwerty287 Jan 5, 2025
ab6b34c
fix metadata panic
qwerty287 Jan 5, 2025
fefaddc
fix test panics
qwerty287 Jan 5, 2025
60bc4ca
fix tests
qwerty287 Jan 5, 2025
d8c4589
fix gitea tag url
qwerty287 Jan 5, 2025
63d3dae
fix lint
qwerty287 Jan 5, 2025
01069a4
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 5, 2025
dbb98a8
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 6, 2025
aaf2e78
Add migration docs and basic UI
qwerty287 Jan 6, 2025
4381882
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 8, 2025
e8bfab7
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 11, 2025
d188398
resolve gitlab tag url
qwerty287 Jan 11, 2025
1b2c4ab
fix github tag url
qwerty287 Jan 11, 2025
a3aba6e
sprintf
qwerty287 Jan 11, 2025
210d8d2
gitlab: load correct release author
qwerty287 Jan 11, 2025
76fb86e
fix web lint
qwerty287 Jan 11, 2025
02ef540
try to fix mysql/postgres
qwerty287 Jan 11, 2025
e4c63a1
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 16, 2025
4397d95
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 17, 2025
3b3f86f
use tag messages
qwerty287 Jan 17, 2025
f1ad9bb
rename release title
qwerty287 Jan 17, 2025
b3164a7
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 19, 2025
3256be3
fix feed
qwerty287 Jan 19, 2025
1968c73
use flex
qwerty287 Jan 19, 2025
11866b4
use trim
qwerty287 Jan 19, 2025
4b6a3c8
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 20, 2025
d66f735
Fix test
qwerty287 Jan 20, 2025
0b2fb85
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 22, 2025
2d18253
disable header linting
qwerty287 Jan 22, 2025
7019c29
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 23, 2025
f3784a6
pr url
qwerty287 Jan 23, 2025
7803d48
solve comment
qwerty287 Jan 23, 2025
538ed3e
Merge branch 'main' into pl-commit-pr
qwerty287 Jan 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions cli/exec/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ var flags = []cli.Flag{
Name: "commit-author-name",
Usage: "Set the metadata environment variable \"CI_COMMIT_AUTHOR\".",
},
&cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_AVATAR"),
Name: "commit-author-avatar",
Usage: "Set the metadata environment variable \"CI_COMMIT_AUTHOR_AVATAR\".",
},
&cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_EMAIL"),
Name: "commit-author-email",
Expand Down Expand Up @@ -365,11 +360,6 @@ var flags = []cli.Flag{
Name: "prev-commit-author-name",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_AUTHOR\".",
},
&cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_AVATAR"),
Name: "prev-commit-author-avatar",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_AUTHOR_AVATAR\".",
},
&cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_EMAIL"),
Name: "prev-commit-author-email",
Expand Down
2 changes: 0 additions & 2 deletions cli/exec/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func metadataFromContext(_ context.Context, c *cli.Command, axis matrix.Axis, w
metadataFileAndOverrideOrDefault(c, "commit-message", func(s string) { m.Curr.Commit.Message = s }, c.String)
metadataFileAndOverrideOrDefault(c, "commit-author-name", func(s string) { m.Curr.Commit.Author.Name = s }, c.String)
metadataFileAndOverrideOrDefault(c, "commit-author-email", func(s string) { m.Curr.Commit.Author.Email = s }, c.String)
metadataFileAndOverrideOrDefault(c, "commit-author-avatar", func(s string) { m.Curr.Commit.Author.Avatar = s }, c.String)

metadataFileAndOverrideOrDefault(c, "commit-pull-labels", func(sl []string) { m.Curr.Commit.PullRequestLabels = sl }, c.StringSlice)
metadataFileAndOverrideOrDefault(c, "commit-release-is-pre", func(b bool) { m.Curr.Commit.IsPrerelease = b }, c.Bool)
Expand All @@ -128,7 +127,6 @@ func metadataFromContext(_ context.Context, c *cli.Command, axis matrix.Axis, w
metadataFileAndOverrideOrDefault(c, "prev-commit-message", func(s string) { m.Prev.Commit.Message = s }, c.String)
metadataFileAndOverrideOrDefault(c, "prev-commit-author-name", func(s string) { m.Prev.Commit.Author.Name = s }, c.String)
metadataFileAndOverrideOrDefault(c, "prev-commit-author-email", func(s string) { m.Prev.Commit.Author.Email = s }, c.String)
metadataFileAndOverrideOrDefault(c, "prev-commit-author-avatar", func(s string) { m.Prev.Commit.Author.Avatar = s }, c.String)

// Workflow
metadataFileAndOverrideOrDefault(c, "workflow-name", func(s string) { m.Workflow.Name = s }, c.String)
Expand Down
4 changes: 4 additions & 0 deletions cli/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func pipelineOutput(c *cli.Command, pipelines []*woodpecker.Pipeline, fd ...io.W
if !noHeader {
table.WriteHeader(cols)
}
table.AddFieldFn("message", func(obj any) string {
pl, _ := obj.(*woodpecker.Pipeline)
return pl.Commit.Message
})
for _, resource := range pipelines {
if err := table.Write(cols, resource); err != nil {
return err
Expand Down
14 changes: 8 additions & 6 deletions cli/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ func TestPipelineOutput(t *testing.T) {

pipelines := []*woodpecker.Pipeline{
{
Number: 1,
Status: "success",
Event: "push",
Branch: "main",
Message: "message\nmultiline",
Author: "John Doe\n",
Number: 1,
Status: "success",
Event: "push",
Branch: "main",
Commit: &woodpecker.Commit{
Message: "message\nmultiline",
},
Author: "John Doe\n",
},
}

Expand Down
114 changes: 73 additions & 41 deletions cmd/server/openapi/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4705,18 +4705,18 @@ const docTemplate = `{
"author_avatar": {
"type": "string"
},
"author_email": {
"type": "string"
},
"branch": {
"type": "string"
},
"commit": {
"type": "string"
"$ref": "#/definitions/model.Commit"
},
"created": {
"type": "integer"
},
"deployment": {
"$ref": "#/definitions/model.Deployment"
},
"event": {
"type": "string"
},
Expand All @@ -4726,18 +4726,21 @@ const docTemplate = `{
"id": {
"type": "integer"
},
"message": {
"type": "string"
},
"number": {
"type": "integer"
},
"pull_request": {
"$ref": "#/definitions/PullRequest"
},
"ref": {
"type": "string"
},
"refspec": {
"type": "string"
},
"release": {
"type": "string"
},
"repo_id": {
"type": "integer"
},
Expand All @@ -4746,9 +4749,6 @@ const docTemplate = `{
},
"status": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -4883,9 +4883,6 @@ const docTemplate = `{
"author_avatar": {
"type": "string"
},
"author_email": {
"type": "string"
},
"branch": {
"type": "string"
},
Expand All @@ -4896,16 +4893,16 @@ const docTemplate = `{
}
},
"commit": {
"type": "string"
"$ref": "#/definitions/model.Commit"
},
"created": {
"type": "integer"
},
"deploy_task": {
"cron": {
"type": "string"
},
"deploy_to": {
"type": "string"
"deployment": {
"$ref": "#/definitions/model.Deployment"
},
"errors": {
"type": "array",
Expand All @@ -4922,58 +4919,42 @@ const docTemplate = `{
"forge_url": {
"type": "string"
},
"from_fork": {
"type": "boolean"
},
"id": {
"type": "integer"
},
"is_prerelease": {
"type": "boolean"
},
"message": {
"type": "string"
},
"number": {
"type": "integer"
},
"parent": {
"type": "integer"
},
"pr_labels": {
"type": "array",
"items": {
"type": "string"
}
"pull_request": {
"$ref": "#/definitions/PullRequest"
},
"ref": {
"type": "string"
},
"refspec": {
"type": "string"
},
"release": {
"type": "string"
},
"reviewed": {
"type": "integer"
},
"reviewed_by": {
"type": "string"
},
"sender": {
"description": "uses reported user for webhooks and name of cron for cron pipelines",
"type": "string"
},
"started": {
"type": "integer"
},
"status": {
"$ref": "#/definitions/StatusValue"
},
"timestamp": {
"type": "integer"
},
"title": {
"type": "string"
},
"updated": {
"type": "integer"
},
Expand Down Expand Up @@ -5008,9 +4989,18 @@ const docTemplate = `{
"PullRequest": {
"type": "object",
"properties": {
"from_fork": {
"type": "boolean"
},
"index": {
"type": "string"
},
"labels": {
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"type": "string"
}
Expand Down Expand Up @@ -5399,9 +5389,6 @@ const docTemplate = `{
"metadata.Author": {
"type": "object",
"properties": {
"avatar": {
"type": "string"
},
"email": {
"type": "string"
},
Expand Down Expand Up @@ -5515,6 +5502,9 @@ const docTemplate = `{
"parent": {
"type": "integer"
},
"release": {
"type": "string"
},
"started": {
"type": "integer"
},
Expand Down Expand Up @@ -5647,6 +5637,48 @@ const docTemplate = `{
"RequireApprovalAllEvents"
]
},
"model.Commit": {
"type": "object",
"properties": {
"author": {
"$ref": "#/definitions/model.CommitAuthor"
},
"forge_url": {
"type": "string"
},
"message": {
"type": "string"
},
"sha": {
"type": "string"
}
}
},
"model.CommitAuthor": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"email": {
"type": "string"
}
}
},
"model.Deployment": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"target": {
"type": "string"
},
"task": {
"type": "string"
}
}
},
"model.ForgeType": {
"type": "string",
"enum": [
Expand Down
2 changes: 0 additions & 2 deletions docs/docs/20-usage/50-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ This is the reference list of all environment variables available to your pipeli
| `CI_COMMIT_MESSAGE` | commit message | `Initial commit` |
| `CI_COMMIT_AUTHOR` | commit author username | `john-doe` |
| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `[email protected]` |
| `CI_COMMIT_AUTHOR_AVATAR` | commit author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` |
| `CI_COMMIT_PRERELEASE` | release is a pre-release (empty if event is not `release`) | `false` |
| | **Current pipeline** | |
| `CI_PIPELINE_NUMBER` | pipeline number | `8` |
Expand Down Expand Up @@ -108,7 +107,6 @@ This is the reference list of all environment variables available to your pipeli
| `CI_PREV_COMMIT_MESSAGE` | previous commit message | `test` |
| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | `john-doe` |
| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | `[email protected]` |
| `CI_PREV_COMMIT_AUTHOR_AVATAR` | previous commit author avatar | `https://git.example.com/avatars/12` |
| | **Previous pipeline** | |
| `CI_PREV_PIPELINE_NUMBER` | previous pipeline number | `7` |
| `CI_PREV_PIPELINE_PARENT` | previous pipeline number of parent pipeline | `0` |
Expand Down
41 changes: 40 additions & 1 deletion docs/src/pages/migrations.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<!-- markdownlint-disable no-duplicate-heading -->

# Migrations

To enhance the usability of Woodpecker and meet evolving security standards, occasional migrations are necessary. While we aim to minimize these changes, some are unavoidable. If you experience significant issues during a migration to a new version, please let us know so maintainers can reassess the updates.

## `next`

- No changes
### User-facing changes

#### API changes

- Changed the pipeline model to have different objects for different event metadata (e.g. pull request title)

## 3.0.0

Expand Down Expand Up @@ -65,6 +71,7 @@ The following built-in environment variables have been removed/replaced:
- `CI_PIPELINE_FINISHED` as it was empty during execution
- `CI_PIPELINE_STATUS` due to always being set to `success`
- `CI_STEP_STATUS` due to always being set to `success`
- `CI_COMMIT_AUTHOR_AVATAR` and `CI_PREV_COMMIT_AUTHOR_AVATAR` as commit authors don't have an avatar
- `WOODPECKER_WEBHOOK_HOST` in favor of `WOODPECKER_EXPERT_WEBHOOK_HOST`

Environment variables which are empty after workflow parsing are not being injected into the build but filtered out beforehand ([#4193](https://github.com/woodpecker-ci/woodpecker/pull/4193))
Expand All @@ -83,6 +90,38 @@ The following syntax deprecations will now result in an error:
- `platform:` ([#3916](https://github.com/woodpecker-ci/woodpecker/pull/3916))
- `branches:` ([#3916](https://github.com/woodpecker-ci/woodpecker/pull/3916))

#### Workflow syntax changes

- Grouping of steps via `steps.[name].group` should now be done using `steps.[name].depends_on`
- The `includes` and `excludes` event filter options have been removed
- Previously, env vars have been automatically sanitized to uppercase.
As this has been confusing, the type-case of the secret definition is now respected ([#3375](https://github.com/woodpecker-ci/woodpecker/pull/3375)).
- `secrets` have been entirely removed in favor of `environment` combined with the `from_secret` syntax.
As `secrets` are just normal env vars which are masked, the goal was to allow them to be declared next to normal env vars and at the same time reduce the keyword syntax count.
Additionally, the `from_secret` syntax gives more flexibility in naming.
Whereas beforehand `secrets` where always named after their initial secret name, the `from_secret` reference can now be different.
Last, one can inject multiple different env vars from the same secret reference.

2.x:

```yaml
secrets: [my_token]
```

3.x:

```yaml
environment:
MY_TOKEN:
from_secret: my_token
```

- The `environment` filter option has been removed in favor of `when.evaluate`

#### API changes

- Removed deprecated `registry/` endpoint. Use `registries`, `/authorize/token`

#### CLI changes

The following restructuring was done to achieve a more consistent grouping:
Expand Down
Loading