i had created a job and in build step i had given below mentioned shell script
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 70%
# -------------------------------------------------------------------------
# set admin email so that you can get email
# set alert level 70% is default
ALERT=70
EXCLUDE_LIST="/net|/home|devfs"
if [ "$EXCLUDE_LIST" != "" ] ; then
df -H | grep -vE "^Filesystem|Users|${EXCLUDE_LIST}" | awk '{ print $5 " " $1 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" > /Users/Shared/Jenkins/disk_space.txt
else
echo "space \"$partition ($usep%)\" on $(hostname) as on $(date)" > /Users/Shared/Jenkins/space.txt
fi
done
fi
After this script executed the email need to be triggered in jenkins if the condition satisfied. otherwise job should run but email should not trigger.