Skip to content

Common tasks

Scheduling pipelines

If you would like to schedule pipelines to run on automatically, separately from the triggers defined by the template above, you can do so with Scheduled Pipelines.

  • Navigate to your project on Drupal GitLab
  • Navigate to Build -> Pipelines schedules in the sidebar.
  • Click New Schedule button.

From here, you can set an interval pattern, such as every day, week, or month, or a custom pattern based on standard cron syntax. You can then choose a target branch or tag, and set any variable values.

Scheduled pipelines

Gathering results

There are multiple ways to gather GitLab CI results, depending on what data you need.

  • You can use the test result summaries from the pipeline, which will highlight test failures and summarize successes.
  • You can download the test artifacts.
  • You can view the full console output of any particular job by clicking through it.

If you need additional debugging, you can also leverage GitLab CI features to capture additional logs from some of the services that are running, by setting CI_DEBUG_SERVICES variable to "true". You can read more about this feature on the GitLab documentation page here. We only recommend this while debugging, as the volume and size of artifacts can grow very rapidly with this feature enabled.

Composer dependencies and configuration

Everything in the module's composer.json is merged into project composer.json.

Alternatively, you can also use the before_script with the --no-update flag to require additional modules.

    - composer require --dev predis/predis --no-update

Including a non-required module for testing.

Add the module to the require-dev section of your module's composer.json file. It will be installed only when requested by developers and the CI process.

Install Javascript libraries.

If packages cannot be installed via composer or yarn, you can still download them directly.

For example, DropzoneJS needs the Dropzone JS library:


    - mkdir $_WEB_ROOT/libraries
    - cd $_WEB_ROOT/libraries
    - curl -L -o --silent$DROPZONE_VERSION/
    - unzip
    - mv dist dropzone

Test multiple database combinations

You can test multiple database types and versions leveraging the parallel:matrix feature. You can see an example in the date_point module.

Remember that core already tests the different database types and versions, so this is only recommended if your module does some operations that can be database-specific and you need to support multiple database drivers (check the allowed images in drupalci_environments project). It can be as easy as doing this in the template:

      - _TARGET_DB_TYPE: 'mysql'
        _TARGET_DB_VERSION: '8'
      - _TARGET_DB_TYPE: 'pgsql'
        _TARGET_DB_VERSION: '16'

Another example could be testing different extensions if a module allows for that. For example, Redis tests run with different extensions:

          - PhpRedis
          - Predis
          - Relay

Concurrent test runs

Projects with more than a few tests can use core's with concurrency feature.


Test different Drupal core and PHP versions

To specify which versions of Drupal Core and PHP are used for running tests, the following "opt_in" variables can be set to 1 or 0. The default values are:


Use only what makes sense for your project. Pipelines for Drupal 9+ make use of all these six variables. Testing with Drupal 7 only uses OPT_IN_TEST_CURRENT and OPT_IN_TEST_MAX_PHP

You can combine the above with manual execution (to save resources and trigger only when needed) by doing something like this:

phpunit (next major):
    - !reference [ .opt-in-next-major-rule ]
    - !reference [ .skip-phpunit-rule ]
    # Do not automatically run, but allow the job to be started manually.
    # To do this the .phpunit-tests-exist-rule is removed from here.
    - when: manual

Viewing environment variables

During development or when debugging a job, you may want to view all the environment variables created in the pipeline. To do this, add the following to your .gitlab-ci.yml file


You can also set this variable in the 'run pipeline' form. The information is displayed in the Composer and PHPunit job log, inside an expandable drop-down which is closed by default. If you want the environment variables to be displayed in other jobs, add the following reference into a before_script or after_script section

  - !reference [ .show-environment-variables ]

Most environment variables are created when the pipeline is first built, but there are a small number which are added in the composer job (and its variants, if these are enabled). These are automatically available in every subsequent job. However, in the rare scenario that you need one of these custom variables in your composer job(s), add the following reference to create the variables in the appropriate before_script or after_script section

  - !reference [ .create-environment-variables ]

Running pipelines via the GitLab UI

You can run pipelines from the GitLab UI by navigating to: Build > Pipelines > Run pipeline. When you do this, all the variables inherited from the templates will be presented in the form and you can override any value. These changes will take priority over any pre-defined value or value set in the .gitlab-ci.yml file.

Creating new jobs that require database and browser services

If you need to create new jobs that require the database and browser to be wired up, you just need to extend from a predefined base job:

  extends: .testing-job-base

This will connect the database and chrome services, in the same way that is done for the phpunit and nightwatch jobs. You still need to set up the rest of the job elements.

You can easily install Drupal inside the job like this: php $_WEB_ROOT/core/scripts/drupal install standard.

A full example could look like the below code:

  extends: .testing-job-base
    - composer
    # Setup the webserver and calculate the database connection information (if needed).
    - !reference [ .setup-webserver ]
    - !reference [ .simpletest-db ]
    - php $_WEB_ROOT/core/scripts/drupal install standard
    # This line could go into the module's composer.json file. It's here for demonstration purposes.
    - composer require drush/drush
    - vendor/bin/drush --root=$_WEB_ROOT st
    # Do something else...