From 7d262f0b94e8ecfdfbc97600d931cfec757af4e3 Mon Sep 17 00:00:00 2001 From: Andre Sencioles Date: Thu, 15 Jun 2017 21:18:44 +1200 Subject: use bare repo instead of working directory Drop requirement for Git working directory by using the bare repository --- extra/oxidized-report-git-commits | 57 ++++++++++++--------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/extra/oxidized-report-git-commits b/extra/oxidized-report-git-commits index 2fd4870..3bf1bbc 100755 --- a/extra/oxidized-report-git-commits +++ b/extra/oxidized-report-git-commits @@ -17,64 +17,41 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# 20170615 - Andre Sencioles +# 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 [ 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}" -- cgit v1.2.1 From 64b8d9e3e4da7ccb87f0ee61d9d00fd72bca4d5b Mon Sep 17 00:00:00 2001 From: Andre Sencioles Date: Thu, 15 Jun 2017 21:20:28 +1200 Subject: check job status --- extra/oxidized-report-git-commits | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extra/oxidized-report-git-commits b/extra/oxidized-report-git-commits index 3bf1bbc..db36ecf 100755 --- a/extra/oxidized-report-git-commits +++ b/extra/oxidized-report-git-commits @@ -39,6 +39,10 @@ echo "Group name: ${OX_NODE_GROUP}" echo "Job status: ${OX_JOB_STATUS}" echo "Job time: ${OX_JOB_TIME}" +if [ "${OX_EVENT}" = "node_fail" ]; then + echo 'Job failed' + exit 64 +fi if [ -z "${OX_REPO_COMMITREF}" ]; then echo '$OX_REPO_COMMITREF not set' -- cgit v1.2.1