Skip to content

Instantly share code, notes, and snippets.

@refactorsaurusrex
Last active January 7, 2020 18:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refactorsaurusrex/fe9ea70187e519e8a4c408e24a69891b to your computer and use it in GitHub Desktop.
Save refactorsaurusrex/fe9ea70187e519e8a4c408e24a69891b to your computer and use it in GitHub Desktop.
Jenkinsfile: How to get the author name for the HEAD commit
AUTHOR_NAME = bat (
script: "git show -s --format='%%an' HEAD",
returnStdout: true
).split('\r\n')[2].trim()
echo "The last commit was written by ${AUTHOR_NAME}."
echo "PS - Jenkins sucks giant monkey balls."
@rdok
Copy link

rdok commented Mar 24, 2019

Patch: Use a single % instead of two.

> git show --help | grep 'author name'
           ·   %an: author name
           ·   %aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))

@CJHarmath
Copy link

Patch: Use a single % instead of two.

You need the double % in the Jenkinsfile which is a groovy script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment