Skip to content

feat: Respect user-defined Git author identity in merges#3946

Open
KrasimirAntonov wants to merge 2 commits intojenkinsci:masterfrom
KrasimirAntonov:master
Open

feat: Respect user-defined Git author identity in merges#3946
KrasimirAntonov wants to merge 2 commits intojenkinsci:masterfrom
KrasimirAntonov:master

Conversation

@KrasimirAntonov
Copy link
Copy Markdown

@KrasimirAntonov KrasimirAntonov commented Apr 2, 2026

Description

Previously, MergeWithGitSCMExtension always used hardcoded values "Jenkins" / "nobody@nowhere" as the author and committer of the merge commit, ignoring any user-configured identity.

The decorateRevisionToBuild method now resolves the identity in the following order:

  1. If a UserIdentity extension is configured in the GitSCM, it is applied via userIdentity.decorate(scm, git).
  2. Otherwise, it falls back to the global descriptor configuration (getGlobalConfigName() / getGlobalConfigEmail()), and only uses "Jenkins" / "nobody@nowhere" when those values are null.

Testing done

Three automated tests were added to MergeWithGitSCMExtensionTest:

  • testMergeCommitUsesDefaultIdentity — verifies that when no identity is configured, the merge commit is authored by Jenkins / nobody@nowhere.
  • testMergeCommitUsesGlobalConfigIdentity — sets globalConfigName / globalConfigEmail on the GitSCM descriptor and verifies the merge commit reflects those values.
  • testMergeCommitUsesUserIdentityExtension — adds a UserIdentity extension to the SCM and verifies it takes precedence over the global config.

All three tests build a real Jenkins freestyle project with a diverging branch scenario and inspect the HEAD commit's PersonIdent via JGit's RevWalk.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests

Krasimir Antonov Valev added 2 commits April 2, 2026 12:48
Ensures merge operations use the configured user identity if available,
falling back to default values only when necessary. Improves consistency
with user preferences and global configuration for commit metadata.
Introduces tests verifying that merge commit author information
is set according to default, global config, or user extension.
Ensures correct identity selection during merges and prevents
regressions in commit attribution logic.
@KrasimirAntonov KrasimirAntonov requested a review from a team as a code owner April 2, 2026 10:58
@github-actions github-actions bot added the tests Automated test addition or improvement label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Automated test addition or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant