After everything is done, you can put this in your script to execute commands remotely (e.g. chown, chmod and the like),
ssh -l root -i ${BUILD_DIR}mykey.pem" $SERVER_IP "chown whateveruser:whatevergroup $SERVER_DIR"
Syntax:
ssh -l root -i key $SERVER_IP "your command"