Add custom variables to set before_script actions in upstream project or via UI

Migrated issue

Reported by: jonathan1055

Related to !4 (closed) !3 (merged) !1 (merged)

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.LineLength rule 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_ACTIONS executed in the phpcs before_script:
  • The optional $BEFORE_SCRIPT_ACTIONS 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

This approach could be extended to other jobs, but first we can get it working on phpcs.