diff options
| author | ytti <saku@ytti.fi> | 2017-07-02 11:29:14 +0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-02 11:29:14 +0300 | 
| commit | 1bc7c1625f3894f6d723bd76ab54d7f7fa85d349 (patch) | |
| tree | 3bad7b8cea462bff91d772f0bdf50c27cea8501c /extra | |
| parent | 51e05d2d1be662c6a805e92f03327d4ab365ab2e (diff) | |
| parent | 64b8d9e3e4da7ccb87f0ee61d9d00fd72bca4d5b (diff) | |
Merge pull request #893 from asenci/report-git-commits
Update report git commits script
Diffstat (limited to 'extra')
| -rwxr-xr-x | extra/oxidized-report-git-commits | 61 | 
1 files changed, 21 insertions, 40 deletions
| diff --git a/extra/oxidized-report-git-commits b/extra/oxidized-report-git-commits index 2fd4870..db36ecf 100755 --- a/extra/oxidized-report-git-commits +++ b/extra/oxidized-report-git-commits @@ -17,64 +17,45 @@  # See the License for the specific language governing permissions and  # limitations under the License.  # +# 20170615 - Andre Sencioles <asenci@gmail.com> +#            Removed requirement for Git working directory +#            Check job status +# +#  # usage: add the following hook to the oxidized config file:  #   # hooks:  #  email_output:  #    type: exec  #    events: [post_store, node_fail] -#    cmd: '/home/oxidized/extra/oxidized-report-git-commits ~/gitdir/ | mail -s "Oxidized updates for ${OX_NODE_NAME}" update-recipient@example.com' +#    cmd: '/home/oxidized/extra/oxidized-report-git-commits | mail -s "Oxidized updates for ${OX_NODE_NAME}" update-recipient@example.com'  #    async: true  #    timeout: 120  #   # -# The script takes a single argument, namely a git working directory name, -# e.g.  "~/gitdir/".  This is only used as a staging directory and should -# not be set to be the same as the git repo directory. -# -PATH=${PATH}:/usr/local/bin:/usr/local/sbin -export PATH +echo "Node name: ${OX_NODE_NAME}" +echo "Group name: ${OX_NODE_GROUP}" +echo "Job status: ${OX_JOB_STATUS}" +echo "Job time: ${OX_JOB_TIME}" -gitdir=$1 +if [ "${OX_EVENT}" = "node_fail" ]; then +    echo 'Job failed' +    exit 64 +fi -if [ X${OX_REPO_COMMITREF} = "X" ]; then -	echo \$OX_REPO_COMMITREF not set +if [ -z "${OX_REPO_COMMITREF}" ]; then +	echo '$OX_REPO_COMMITREF not set'  	exit 64  fi -if [ X${OX_REPO_NAME} = "X" ]; then -	echo \$OX_REPO_NAME not set +if [ -z "${OX_REPO_NAME}" ]; then +	echo '$OX_REPO_NAME not set'  	exit 64  fi -if [ ! -d ${gitdir}/.git ]; then -	git clone -q ${OX_REPO_NAME} ${gitdir} - -	ret=$? -	if [ X"${ret}" != X0 ] && [ X"${ret}" != X1 ]; then -		echo git clone failed: aborting. -		exit 128 -	fi -fi - -cd ${gitdir} - -git pull -q > /dev/null 2>&1  -ret=$? -if [ X"${ret}" != X0 ] && [ X"${ret}" != X1 ]; then -	echo git pull failed: aborting. -	exit 128 -fi - -# Git is probably working at this stage, so safe to emit more info - -echo "Node name: ${OX_NODE_NAME}" -echo "Group Name: ${OX_NODE_GROUP}" -echo "Job Time: ${OX_JOB_TIME}" -echo "Git Commit ID: ${OX_REPO_COMMITREF}" -echo "Git Repo: ${OX_REPO_NAME}" -echo "Local working dir: ${gitdir}" +echo "Git repo: ${OX_REPO_NAME}" +echo "Git commit ID: ${OX_REPO_COMMITREF}"  echo "" -git diff --no-color ${OX_REPO_COMMITREF}~1..${OX_REPO_COMMITREF} +git --bare --git-dir="${OX_REPO_NAME}" diff --no-color "${OX_REPO_COMMITREF}~1..${OX_REPO_COMMITREF}" | 
