GitLab CI problem with implement Build Stage

I have a problem. I dont know how to implement my automation project (maven + TesNG + java) with GitLab CI. My idea is , when do Push to Master Run the job “Build”. if the project not compile… dont accept this push.
help me ! I find a lot of tutorial but,
none talks about projects with maven java and testng.