Yo, so the main reason that its not working is because the stages keyword in your .gitlab.yml file overwrites the stages. Since .pre is a special stage that isn't listed in .gitlab.yml, it gets ignored when you define stages:.
Just add - .pre to stages .
include:
- local: "prestage.yml"
stages:
- .pre # Add here
- build
- test
job1:
stage: build
script:
- echo "This job runs in the build stage."
job2:
stage: test
script:
- echo "This job runs in the test stage."
Other settings leave as it is was. And it should work