Information for: DEVELOPERS   PARTNERS   SUPPORT

Customizing a default Code Studio pipeline

Environment variables

The Code Studio pipeline is ready-for-use and out-of-the-box. However, it is also customizable to fit the needs of different projects.

You can use environment variables to:

  • Override default values of the CI/CD pipeline

  • Enable or disable specific jobs

  • Set custom or specific parameters for the CI/CD pipeline

    For example, you can set an environment variable so that the pipeline is aware of the PHP version in your repository.

Customizing the Code Studio pipeline

For any default job run by Code Studio AutoDevOps, you can:

  • Enable or disable the job using an environment variable.
  • Add a before_script to execute your own custom script before the Code Studio script.
  • Replace the default script with your own custom script.
  • Add an after_script to execute your own custom script after the Code Studio script.

Enabling or disabling a default Code Studio job

To enable or disable the job, you can set any of the following values to “true” or “false” by going to Settings > CI/CD > Variables or adding in .gitlab-ci.yml:

Environment variable name Description Default value
ACQUIA_JOBS_BUILD_DRUPAL

Enables or disables the Build Code job of the Auto DevOps pipeline.

When set to true, the Build Code and Manage Secrets jobs execute.

True
ACQUIA_JOBS_TEST_DRUPAL
(affects both BLT Test Drupal and Test Drupal jobs)

Enables or disables the Test Drupal stage of the Auto DevOps pipeline.

When set to true, the Test Drupal job executes.

True
ACQUIA_JOBS_CREATE_CDE

Enables or disables the Acquia Continuous Delivery Environment (CDE) creation during the Deploy Drupal stage.

When set to true, this creates an Acquia CDE during the merge process for Automatic Updates.

Note

  • You must have an Acquia Cloud CD entitlement for this feature to work with Code Studio.
  • Site Factory does not support CDEs. Set this variable to false when using a Site Factory application with Code Studio.
True
ACQUIA_JOBS_DEPRECATED_UPDATE

Enables or disables the Deprecated Code Update job of Automatic Updates.

When set to true, the Deprecated Code Update job runs at the scheduled time.

True
ACQUIA_JOBS_COMPOSER_UPDATE

Enables or disables the Composer Update job of Automatic Updates.

When set to true, the Composer Update job runs at the scheduled time.

True
ACQUIA_TASKS_SETUP_DRUPAL

Enables Drupal setup upon Composer install during the following jobs:

True
ACQUIA_TASKS_SETUP_DRUPAL_STRATEGY

Installs acquia_cms through install Drupal.

This variable also syncs drush cache:rebuild and import config.

Install, sync
ACQUIA_TASKS_SETUP_DRUPAL_PROFILE

The name of the Drupal profile used during drush site:install.

It is effective if ACQUIA_TASKS_SETUP_DRUPAL is set to true.

acquia_cms
ACQUIA_TASKS_SETUP_DRUPAL_CONFIG_IMPORT

Performs config import using drush config:import.

It is effective if ACQUIA_TASKS_SETUP_DRUPAL is set to true.

True
ACQUIA_JOBS_CREATE_TAG_ARTIFACT Creates or reflects a tagged release made in Code Studio on Cloud Platform as part of the Create artifact from tag job under the Deploy Drupal stage. True
ACQUIA_JOBS_DEPLOY_TAG_ARTIFACT

When set to true, this job automates the tag creation process during deployment to the production environment in Cloud Platform under the Deploy Drupal stage.

For more information on how to enable deploy tags, see Enabling deploy tags in Code Studio.

False
SAST_EXCLUDED_PATHS

A vulnerability filter from GitLab.

All Acquia-managed SAST scan jobs for Drupal run as part of the Test Drupal stage of the Auto DevOps pipeline.

spec, test, tests, tmp, node_modules, vendor, contrib, core
ACQUIA_CLOUD_SOURCE_DATABASE_NAME Used when the database name is not found. Code Studio fetches the database name at run time. Null
ACQUIA_CLOUD_SOURCE_ENVIRONMENT_ID

Used when an environment ID variable is not found. Code Studio fetches the environment name at run time.

To automatically deploy tags to an environment other than production, set the variable to the environment ID of your target environment. For more information, see Deploy Drupal stage.

Null
PHP_VERSION The PHP version that the project is running. The valid values are 7.4, 8.0, and 8.1. 8.0

For example:

include:
  - project: 'acquia/standard-template'
    file:
      - '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'
variables:
  - ACQUIA_JOBS_CREATE_CDE: “false”

Adding a before_script or after_script to a Code Studio job

include:
  - project: 'acquia/standard-template'
    file:
      - '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'
"Test Drupal":
  before_script:
    - echo “Hello world!”

Building front-end dependencies

A common use case for customizing a job is to build front-end dependencies. There are many ways you can do this. For example, you can create a custom Composer script named build-theme and call it during a CI/CD build.

An advantage of wrapping your commands in a Composer script is that you can easily run the command during a build, and also within your IDE.

For example, in composer.json

  "scripts": {
       "build-theme": ["[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\" && cd
docroot/themes/custom/mytheme && nvm install && nvm use && npm install && npm run build"]
   }

For example, in .gitlab-ci.yml:

"Deploy Branch to Acquia":
  before_script:
    - composer run-script build-theme

"Deploy Tag to Acquia":
  before_script:
    - composer run-script build-theme

You can then run composer run-script build-theme in an IDE whenever you need to build theme dependencies.

Using BLT with Code Studio

Code Studio is built to easily integrate with BLT (Build and Launch Tool). Using both tools, you can quickly have an advanced, comprehensive Drupal CI/CD workflow running in a couple of minutes.

  1. Run the following command to add BLT:

    composer require acquia/blt
    
  2. In blt/blt.yml, place your Cloud Platform application Git URL in the git.remotes array, and then disable the Git hooks:

    git:
        remotes:
            - [email protected]:foo.git
        hooks:
            pre-commit: false
            pre-push: false
            commit-msg: false
    
  3. Commit and push your changes.

    Code Studio now uses BLT in AutoDev Ops.