Make sure each script: starts in the intended directory
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3503966. -->
Reported by: [jonathan1055](https://www.drupal.org/user/92645)
Related to !327
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When working on <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/gitlab_templates_downstream/issues/3503851" title="Status: Closed (fixed)">#3503851: Add custom variables to set before_script actions in upstream project or via UI</a></span> to test <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/gitlab_templates/issues/3380694" title="Status: Closed (fixed)">#3380694: Add basepath parameter to PHP Code Sniffer so that paths are relative</a></span> I realised that many of the <code>script:</code> sections in the template rely/expect/assume the working directory is the default from when the job started. But any custom <code>before_script:</code> could have changed the working directory, which would cause the job to fail.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>At the start of every <code>script:</code> execute the require <code>cd $CI_PROJECT_DIR/path/we/need && pwd</code> to fix and confirm the working directory.</p>
<p>This has several benefits</p>
<ul>
<li>It will save developer time working out why the job fails</li>
<li>It will reduce support hours</li>
<li>It documents very clearly in code and log where the job script is being run. </li>
</ul>
issue