Add custom variables to set before_script actions in upstream project or via UI
Problem/Motivation
When testing changes such and PHPCS, for example in gitlab_templates#3380694 (closed) 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.
Solution implemented
- Each branch has a .gitlab/phpcs.xml file, which is not used by default.
- This file contains a
Drupal.Files.LineLengthrule with a reduced length of 30, so that the phpcs would fail if the file was active - When required, this file is moved to the project folder via a keyword in
$BEFORE_SCRIPT_ACTIONSexecuted in the phpcsbefore_script: - The optional
$BEFORE_SCRIPT_ACTIONScan 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
This approach could be extended to other jobs, but first we can get it working on phpcs.