[XDA-University] mithun46:
For All Who Build on a server. This is the Script That I Use. It's There on My Github also.This Will make clean, build rom, upload to your ftp server :D

#!/bin/bash

# leave alone
DATE=`eval date +%m`-`eval date +%d`
exec ssh-agent bash && ssh-add

#-------------------ROMS To Be Built------------------#

PRODUCT[0]="n7100"	# phone model name (product folder name)
BRNCHCMD[0]="n7100"	# lunch command used for ROM
BUILDNME[0]="ReVolt_n7100_$DATE"	# name of the output ROM in the out folder
OUTPUTNME[0]="ReVolt_n7100_$DATE"	# what you want the new name to be

#---------------------Build Settings------------------#

# should they be moved out of the output folder
# like a dropbox or other cloud storage folder
# or any other folder you want
# also required for FTP upload
MOVE=y

# folder they should be moved to
cd $HOME
mkdir cloud/storage/directory
STORAGE=/cloud/storage/directory

# your build source code directory path
SAUCE=/home/?????????????/ReVolt-ROM

# number for the -j parameter
J=12

# generate an MD5
MD5=y

# sync repositories
SYNC=y

# run make clean first
CLEAN=y

#----------------------FTP Settings--------------------#

# set "FTP=y" if you want to enable FTP uploading
# must have moving to storage folder enabled first
FTP=n

# FTP server settings - Create One In 1freehosting.com for free [{ THEY GIVE 10 GB Free}]
FTPHOST[0]="HostName"	# ftp hostname
FTPUSER[0]="UserName"	# ftp username
FTPPASS[0]="Password"	# ftp password
FTPDIR[0]="public_html"	# ftp upload directory

#---------------------Build Bot Code-------------------#

echo -n "Moving to source directory..."
cd $SAUCE
echo "done!"

if [ $SYNC = "y" ]; then
echo -n "Running repo sync..."
repo sync
echo "done!"
fi

if [ $CLEAN = "y" ]; then
echo -n "Running make clean..."
make clean
echo "done!"
fi

for VAL in "${!PRODUCT[@]}"
do
echo -n "Starting build..."
source build/envsetup.sh && brunch ${BRNCHCMD[$VAL]}
echo "done!"

if [ $MD5 = "y" ]; then
echo -n "Generating MD5..."
md5sum $SAUCE/out/target/product/${PRODUCT[$VAL]}/${BUILDNME[$VAL]}$DATE".zip" | sed 's|'$SAUCE'/out/target/product/'${PRODUCT[$VAL]}'/||g' > $SAUCE/out/target/product/${PRODUCT[$VAL]}/${BUILDNME[$VAL]}$DATE".md5sum.txt"
echo "done!"
fi

if [ $MOVE = "y" ]; then
echo -n "Moving to cloud storage directory..."
mv $SAUCE/out/target/product/${PRODUCT[$VAL]}/${BUILDNME[$VAL]}$DATE".zip" $STORAGE/${OUTPUTNME[$VAL]}"-"$DATE".zip"
if [ $MD5 = "y" ]; then
mv $SAUCE/out/target/${PRODUCT[$VAL]}${BUILDNME[$VAL]}$DATE".md5sum.txt" $STORAGE/${OUTPUTNME[$VAL]}$DATE".md5sum.txt"
fi
echo "done!"
fi

done

#----------------------FTP Upload Code--------------------#

if [ $FTP = "y" ]; then
echo "Initiating FTP connection..."

cd $STORAGE
ATTACHROM=`for file in *"-"$DATE".zip"; do echo -n -e "put ${file}\n"; done`
if [ $MD5 = "y" ]; then
ATTACHMD5=`for file in *"-"$DATE".md5sum.txt"; do echo -n -e "put ${file}\n"; done`
ATTACH=$ATTACHROM"/n"$ATTACHMD5
else
ATTACH=$ATTACHROM
fi

for VAL in "${!FTPHOST[@]}"
do
echo -e "\nConnecting to ${FTPHOST[$VAL]} with user ${FTPUSER[$VAL]}..."
ftp -nv <<EOF
open ${FTPHOST[$VAL]}
user ${FTPUSER[$VAL]} ${FTPPASS[$VAL]}
tick
cd ${FTPDIR[$VAL]}
$ATTACH
quit
EOF
done

echo -e "FTP transfer complete! \n"
fi
#----------------------Don't Be Messy--------------------#
cd $HOME
rm -r cloud
echo "All done!"
done