Detect when the Build button was pressed

Is there a way to know when the Build button was pressed? (the one in Build Settings).
I want to show a popup before the build starts.

I don’t think you can do it quite like that, but take a look at the build pipeline.

It’s quite easy to make your own panel to show in Unity’s UI with a “build” button, and make it do whatever you like. This also removes the need to navigate to the player settings when you want to make a build.
You can also perform post processing tasks if you need to.

Since 2017.1 it is now possible to override the Build and Build and Run Buttons.