Git shortlog does not show output in Jenkins shell
Asked Answered
W

1

7

Facing some wired issue while working with Jenkins,

#!/bin/sh

set -x

#initialize environment
export PATH="$HOME/.gem/ruby/2.0.0/bin:$PATH"
export PATH="$HOME/.fastlane/bin:$PATH"
export LC_CTYPE=en_US.UTF-8

cd ~/autobuild/projects/MyAPP
git checkout dev
git reset head --hard
git pull

git shortlog

git log

When i run this above script from Jenkins job, it shows git log output fine, but nothing for git shortlog. Whats the issue? MyApp has hundreds of commits.

Whitener answered 27/3, 2017 at 8:41 Comment(0)
W
16

Finally I was able to find the reason, git shortlog works fine when you directly use from terminal because,

git help shortlog

Shows,

If no revisions are passed on the command line and either standard input is not a terminal or there is no current branch, git shortlog will output a summary of the log read from standard input, without reference to the current repository.

So you must provide the reference explicitly while working with shell scripts,

git shortlog HEAD

Will work fine in that case.

Whitener answered 27/3, 2017 at 9:14 Comment(1)
Thanks for this. git manages to astonish once more :-)Appetence

© 2022 - 2024 — McMap. All rights reserved.