I have a Jenkins pipeline that automatically builds the latest code from a Git repository whenever there's a code update. The problem is that sometimes there are 2 or more code updates happening at (almost) the same time, which causes 2 builds to run in parallel.
I assume this won't happen if I set the number of executors in my node to 1, but I don't want to do that.
Is there any way to make sure a build only starts when previous build (of the same job/pipeline) is finished?