Make sure each script: starts in the intended directory
Problem/Motivation
When working on #3503851: Add custom variables to set before_script actions in upstream project or via UI to test #3380694: Add basepath parameter to PHP Code Sniffer so that paths are relative I realised that many of the script: sections in the template rely/expect/assume the working directory is the default from when the job started. But any custom before_script: could have changed the working directory, which would cause the job to fail.
Proposed resolution
At the start of every script: execute the require cd $CI_PROJECT_DIR/path/we/need && pwd to fix and confirm the working directory.
This has several benefits
- It will save developer time working out why the job fails
- It will reduce support hours
- It documents very clearly in code and log where the job script is being run.