This is called trench warfare!
The name comes from the trenches, that is the ditches that the soldiers built.
This warfare was typical in the First World War and it led to frequent stalemates: the trenches are easy to defend but hard to attack so for long periods of times the front remained stable.