Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git shortlog does not show output in Jenkins shell

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.

like image 411
Sazzad Hissain Khan Avatar asked Mar 27 '17 08:03

Sazzad Hissain Khan


1 Answers

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.

like image 158
Sazzad Hissain Khan Avatar answered Nov 18 '22 04:11

Sazzad Hissain Khan