Add custom variables to set before_script actions in upstream project or via UI
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3503851. -->
Reported by: [jonathan1055](https://www.drupal.org/user/92645)
Related to !4 !3 !1
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When testing changes such and PHPCS, for example in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/gitlab_templates/-/issues/3380694" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/gitlab_templates/-/issues/3380694</a></span> we need to make the downstream projects have phpcs failures to properly test the changes. But we don't want a permanent commit with a coding standards fault, otherwise it will affect other MR tests. It is tedious to commit a failure and then have to revert it after each test.</p>
<h3 id="summary-proposed-resolution">Solution implemented</h3>
<ul>
<li>Each branch has a .gitlab/phpcs.xml file, which is not used by default.</li>
<li>This file contains a <code>Drupal.Files.LineLength</code> rule with a reduced length of 30, so that the phpcs would fail if the file was active</li>
<li>When required, this file is moved to the project folder via a keyword in <code>$BEFORE_SCRIPT_ACTIONS</code> executed in the phpcs <code>before_script:</code></li>
<li>The optional <code>$BEFORE_SCRIPT_ACTIONS</code> can be specified in the upstream (gitlab templates) .gitlab-ci.yml jobs that trigger these pipelines, or via the UI form when running a pipeline manually</li>
</ul>
<p>This approach could be extended to other jobs, but first we can get it working on phpcs.</p>
issue