1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-09-16 08:46:30 +02:00

Add pipeline author and avatar env vars (#5227)

This commit is contained in:
qwerty287
2025-06-27 13:18:33 +03:00
committed by GitHub
parent c1ad196534
commit 2184407dd3
6 changed files with 20 additions and 3 deletions

View File

@@ -5596,6 +5596,12 @@ const docTemplate = `{
"metadata.Pipeline": { "metadata.Pipeline": {
"type": "object", "type": "object",
"properties": { "properties": {
"author": {
"type": "string"
},
"avatar": {
"type": "string"
},
"commit": { "commit": {
"$ref": "#/definitions/metadata.Commit" "$ref": "#/definitions/metadata.Commit"
}, },

View File

@@ -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_MESSAGE` | commit message | `Initial commit` |
| `CI_COMMIT_AUTHOR` | commit author username | `john-doe` | | `CI_COMMIT_AUTHOR` | commit author username | `john-doe` |
| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `john-doe@example.com` | | `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` | | `CI_COMMIT_PRERELEASE` | release is a pre-release (empty if event is not `release`) | `false` |
| | **Current pipeline** | | | | **Current pipeline** | |
| `CI_PIPELINE_NUMBER` | pipeline number | `8` | | `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_CREATED` | pipeline created UNIX timestamp | `1722617519` |
| `CI_PIPELINE_STARTED` | pipeline started 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_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** | | | | **Current workflow** | |
| `CI_WORKFLOW_NAME` | workflow name | `release` | | `CI_WORKFLOW_NAME` | workflow name | `release` |
| | **Current step** | | | | **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_MESSAGE` | previous commit message | `test` |
| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | `john-doe` | | `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_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** | | | | **Previous pipeline** | |
| `CI_PREV_PIPELINE_NUMBER` | previous pipeline number | `7` | | `CI_PREV_PIPELINE_NUMBER` | previous pipeline number | `7` |
| `CI_PREV_PIPELINE_PARENT` | previous pipeline number of parent pipeline | `0` | | `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_CREATED` | previous pipeline created UNIX timestamp | `1722610173` |
| `CI_PREV_PIPELINE_STARTED` | previous pipeline started 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_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` | | `CI_WORKSPACE` | Path of the workspace where source code gets cloned to | `/woodpecker/src/git.example.com/john-doe/my-repo` |
| | **System** | | | | **System** | |

View File

@@ -5,6 +5,7 @@ To enhance the usability of Woodpecker and meet evolving security standards, occ
## `next` ## `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. - (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 ## 3.0.0

View File

@@ -74,6 +74,8 @@ func (m *Metadata) Environ() map[string]string {
setNonEmptyEnvVar(params, "CI_PIPELINE_DEPLOY_TASK", pipeline.DeployTask) setNonEmptyEnvVar(params, "CI_PIPELINE_DEPLOY_TASK", pipeline.DeployTask)
setNonEmptyEnvVar(params, "CI_PIPELINE_CREATED", strconv.FormatInt(pipeline.Created, 10)) setNonEmptyEnvVar(params, "CI_PIPELINE_CREATED", strconv.FormatInt(pipeline.Created, 10))
setNonEmptyEnvVar(params, "CI_PIPELINE_STARTED", strconv.FormatInt(pipeline.Started, 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 workflow := m.Workflow
setNonEmptyEnvVar(params, "CI_WORKFLOW_NAME", workflow.Name) 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_CREATED", strconv.FormatInt(prevPipeline.Created, 10))
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_STARTED", strconv.FormatInt(prevPipeline.Started, 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_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 prevCommit := prevPipeline.Commit
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SHA", prevCommit.Sha) setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SHA", prevCommit.Sha)

View File

@@ -55,6 +55,8 @@ type (
Commit Commit `json:"commit,omitempty"` Commit Commit `json:"commit,omitempty"`
Parent int64 `json:"parent,omitempty"` Parent int64 `json:"parent,omitempty"`
Cron string `json:"cron,omitempty"` Cron string `json:"cron,omitempty"`
Author string `json:"author,omitempty"`
Avatar string `json:"avatar,omitempty"`
} }
// Commit defines runtime metadata for a commit. // Commit defines runtime metadata for a commit.

View File

@@ -136,6 +136,8 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b
PullRequestLabels: pipeline.PullRequestLabels, PullRequestLabels: pipeline.PullRequestLabels,
IsPrerelease: pipeline.IsPrerelease, IsPrerelease: pipeline.IsPrerelease,
}, },
Cron: cron, Cron: cron,
Author: pipeline.Author,
Avatar: pipeline.Avatar,
} }
} }