woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.07k stars 351 forks source link

Environment Variable CI_COMMIT_AUTHOR_EMAIL is wrong #2971

Open philipkozeny opened 8 months ago

philipkozeny commented 8 months ago

Component

server, agent

Describe the bug

I am running Gitea with Woodpecker CI. I have noticed that for some time now, the built in CI_COMMIT_AUTHOR_EMAIL environment variable is wrong. I have setup a sample project, with nothing more than a simple pipeline.

Here is the git log from the CLI:

commit 3d6d4085e41d1a044a67c15ddb99a7ea4746ded7 (HEAD -> main, origin/main, origin/HEAD)
Author: Philip Kozeny <philip.kozeny@mydomain.com>
Date:   Tue Dec 19 10:32:26 2023 +0000

    Update .woodpecker.yml

Here is the woodpecker.yml

steps:
  build:
    image: alpine:edge
    commands:
      - echo $CI_COMMIT_AUTHOR
      - echo $CI_COMMIT_AUTHOR_EMAIL

Here is the output after running the pipeline:

+ echo $CI_COMMIT_AUTHOR
philip.kozeny
+ echo $CI_COMMIT_AUTHOR_EMAIL
philip.kozeny@anotherdomain.com

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"2.0.0"}
Powered by Gitea Version: 1.21.2

Additional context

No response

Validations

philipkozeny commented 8 months ago

I have further investigated the issue and I can see that in the web hook gitea sends something strange.

For the commits, head_commit, etc. the info is correct, the pusher data has the wrong mail though. So this might be an Gitea issue.

Example of the payload:

{
  "ref": "refs/heads/main",
  "before": "a930081ca449a21d4416bdeb345bc4d3181b916e",
  "after": "3d6d4085e41d1a044a67c15ddb99a7ea4746ded7",
  "compare_url": "xxxx/compare/a930081ca449a21d4416bdeb345bc4d3181b916e...3d6d4085e41d1a044a67c15ddb99a7ea4746ded7",
  "commits": [
    {
      "id": "3d6d4085e41d1a044a67c15ddb99a7ea4746ded7",
      "message": "Update .woodpecker.yml\n",
      "url": "xxxx/commit/3d6d4085e41d1a044a67c15ddb99a7ea4746ded7",
      "author": {
        "name": "Philip Kozeny",
        "email": "philip.kozeny@mydomain.com",
        "username": "philip.kozeny"
      },
      "committer": {
        "name": "Philip Kozeny",
        "email": "philip.kozeny@mydomain.com",
        "username": "philip.kozeny"
      },
      "verification": null,
      "timestamp": "2023-12-19T10:32:26Z",
      "added": [],
      "removed": [],
      "modified": [
        ".woodpecker.yml"
      ]
    }
  ],
  "total_commits": 1,
  "head_commit": {
    "id": "3d6d4085e41d1a044a67c15ddb99a7ea4746ded7",
    "message": "Update .woodpecker.yml\n",
    "url": "xxx/commit/3d6d4085e41d1a044a67c15ddb99a7ea4746ded7",
    "author": {
      "name": "Philip Kozeny",
      "email": "philip.kozeny@mydomain.com",
      "username": "philip.kozeny"
    },
    "committer": {
      "name": "Philip Kozeny",
      "email": "philip.kozeny@mydomain.com",
      "username": "philip.kozeny"
    },
    "verification": null,
    "timestamp": "2023-12-19T10:32:26Z",
    "added": [],
    "removed": [],
    "modified": [
      ".woodpecker.yml"
    ]
  },
...
  "pusher": {
    "id": 1,
    "login": "philip.kozeny",
    "login_name": "",
    "full_name": "Philip Kozeny",
    "email": "philip.kozeny@anotherdomain.com",
    ...
  },
  "sender": {
    "id": 1,
    "login": "philip.kozeny",
    "login_name": "",
    "full_name": "Philip Kozeny",
    "email": "philip.kozeny@anotherdomain.com",
    ...
    "username": "philip.kozeny"
  }
}
wxiaoguang commented 8 months ago

IIRC:


More context: https://github.com/go-gitea/gitea/issues/28532

philipkozeny commented 8 months ago

IIRC:

  • commiter email: the email in your git commit
  • pusher email: the user email of the Gitea user

More context: go-gitea/gitea#28532

For Woodpecker wouldn't it make more sense to set environment variables like CI_COMMITAUTHOR... to the author of the commit, not the user who did the push?