diff --git a/cmd/server/openapi/docs.go b/cmd/server/openapi/docs.go index cbe3ed13d..0ae125a3c 100644 --- a/cmd/server/openapi/docs.go +++ b/cmd/server/openapi/docs.go @@ -5596,6 +5596,12 @@ const docTemplate = `{ "metadata.Pipeline": { "type": "object", "properties": { + "author": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "commit": { "$ref": "#/definitions/metadata.Commit" }, diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 746cb7634..5ef8553c4 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -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 | `john-doe@example.com` | -| `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` | @@ -90,6 +89,8 @@ This is the reference list of all environment variables available to your pipeli | `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | `1722617519` | | `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | `1722617519` | | `CI_PIPELINE_FILES` | changed files (empty if event is not `push` or `pull_request`), it is undefined if more than 500 files are touched | `[]`, `[".woodpecker.yml","README.md"]` | +| `CI_PIPELINE_AUTHOR` | pipeline author username | `octocat` | +| `CI_PIPELINE_AVATAR` | pipeline author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` | | | **Current workflow** | | | `CI_WORKFLOW_NAME` | workflow name | `release` | | | **Current step** | | @@ -108,7 +109,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 | `john-doe@example.com` | -| `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` | @@ -121,6 +121,8 @@ This is the reference list of all environment variables available to your pipeli | `CI_PREV_PIPELINE_CREATED` | previous pipeline created UNIX timestamp | `1722610173` | | `CI_PREV_PIPELINE_STARTED` | previous pipeline started UNIX timestamp | `1722610173` | | `CI_PREV_PIPELINE_FINISHED` | previous pipeline finished UNIX timestamp | `1722610383` | +| `CI_PREV_PIPELINE_AUTHOR` | previous pipeline author username | `octocat` | +| `CI_PREV_PIPELINE_AVATAR` | previous pipeline author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` | | |   | | | `CI_WORKSPACE` | Path of the workspace where source code gets cloned to | `/woodpecker/src/git.example.com/john-doe/my-repo` | | | **System** | | diff --git a/docs/src/pages/migrations.md b/docs/src/pages/migrations.md index f94027ca8..3c56e8478 100644 --- a/docs/src/pages/migrations.md +++ b/docs/src/pages/migrations.md @@ -5,6 +5,7 @@ To enhance the usability of Woodpecker and meet evolving security standards, occ ## `next` - (Kubernetes) Deprecated `step` label on pod in favor of new namespaced label `woodpecker-ci.org/step`. The `step` label will be removed in a future update. +- deprecated `CI_COMMIT_AUTHOR_AVATAR` and `CI_PREV_COMMIT_AUTHOR_AVATAR` env vars in favor of `CI_PIPELINE_AVATAR` and `CI_PREV_PIPELINE_AVATAR` ## 3.0.0 diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index d95ac8762..13dfdf76b 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -74,6 +74,8 @@ func (m *Metadata) Environ() map[string]string { setNonEmptyEnvVar(params, "CI_PIPELINE_DEPLOY_TASK", pipeline.DeployTask) setNonEmptyEnvVar(params, "CI_PIPELINE_CREATED", strconv.FormatInt(pipeline.Created, 10)) setNonEmptyEnvVar(params, "CI_PIPELINE_STARTED", strconv.FormatInt(pipeline.Started, 10)) + setNonEmptyEnvVar(params, "CI_PIPELINE_AUTHOR", pipeline.Author) + setNonEmptyEnvVar(params, "CI_PIPELINE_AVATAR", pipeline.Avatar) workflow := m.Workflow setNonEmptyEnvVar(params, "CI_WORKFLOW_NAME", workflow.Name) @@ -134,6 +136,8 @@ func (m *Metadata) Environ() map[string]string { setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_CREATED", strconv.FormatInt(prevPipeline.Created, 10)) setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_STARTED", strconv.FormatInt(prevPipeline.Started, 10)) setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_FINISHED", strconv.FormatInt(prevPipeline.Finished, 10)) + setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_AUTHOR", prevPipeline.Author) + setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_AVATAR", prevPipeline.Avatar) prevCommit := prevPipeline.Commit setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SHA", prevCommit.Sha) diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index 7b1084f65..9a617c814 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -55,6 +55,8 @@ type ( Commit Commit `json:"commit,omitempty"` Parent int64 `json:"parent,omitempty"` Cron string `json:"cron,omitempty"` + Author string `json:"author,omitempty"` + Avatar string `json:"avatar,omitempty"` } // Commit defines runtime metadata for a commit. diff --git a/server/pipeline/stepbuilder/metadata.go b/server/pipeline/stepbuilder/metadata.go index 8ceb0dbcd..badb0eb24 100644 --- a/server/pipeline/stepbuilder/metadata.go +++ b/server/pipeline/stepbuilder/metadata.go @@ -136,6 +136,8 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b PullRequestLabels: pipeline.PullRequestLabels, IsPrerelease: pipeline.IsPrerelease, }, - Cron: cron, + Cron: cron, + Author: pipeline.Author, + Avatar: pipeline.Avatar, } }