To use a custom .gitlab-ci.yml
file to customize a default Code Studio
pipeline, change the CI/CD configuration file path of the project:
Click Settings > CI/CD.
In the General pipelines section, click Expand and then enter the path to the
custom .gitlab-ci.yml
file.
Click Save changes.
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.
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.
Click Settings > CI/CD.
In the Variables section, click Expand and then click Add variable.
In the Add variable dialog box, specify the appropriate value in each field.
Click Add variable.
You can also add environment variables through the .gitlab-ci.yml
file.
For example:
include:
- project: 'acquia/standard-template'
file:
- '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'
variables:
- ACQUIA_JOBS_CREATE_CDE: "true"
Click Settings > CI/CD.
In the Variables section, click Expand and then click the pencil icon next to the environment variable that you want to edit.
In the Update variable dialog box, change the value of the environment variable.
To configure the environment variables for enabling or disabling a CI/CD job, see Environment variables to enable or disable a CI/CD job.
To configure other environment variables, see Other environment variables.
Click Update variable.
You can also edit environment variables through the .gitlab-ci.yml
file.
For example:
include:
- project: 'acquia/standard-template'
file:
- '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'
variables:
- ACQUIA_JOBS_CREATE_CDE: "false"
Environment variable name |
Description |
Default value |
---|---|---|
|
Enables or disables the Build Code job of the Auto DevOps pipeline. When set to |
|
|
Enables or disables the Test Drupal stage of the Auto DevOps pipeline. When set to |
|
|
Enables or disables the Acquia Continuous Delivery Environment (CDE) creation during the Deploy Drupal stage. When set to Note
|
|
|
Enables or disables the Deprecated Code Update job of Automatic Updates. When set to |
|
|
Enables or disables the Composer Update job of Automatic Updates. When set to |
|
|
Enables or disables the Validate Code Structure job of the Auto DevOps pipeline. When set to |
|
|
Enables Drupal setup upon Composer install during the following jobs:
|
|
|
Performs config import using It is effective if |
|
|
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. |
|
|
When set to For more information on how to enable deploy tags, see Enabling deploy tags in Code Studio. |
|
Environment variable name |
Description |
Default value |
---|---|---|
|
Determines if Code Studio installs a clean version of Drupal using an install
profile that This variable also syncs |
install, sync |
|
The name of the Drupal profile used during If |
minimal |
|
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 |
|
Used when the database name is not found. Code Studio fetches the database name at run time. |
null |
|
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 |
|
The PHP version that the project is running. The valid values are 8.0, 8.1, and 8.2. |
8.0 |
include:
- project: 'acquia/standard-template'
file:
- '/gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml'
"Test Drupal":
before_script:
- echo “Hello world!”
A common use case for customizing a job is to build front-end dependencies. You can do it in many ways. For example, you can:
Add a post-install-cmd
to your composer.json
file.
Create a custom Composer script
named build-theme
and call it during a CI/CD job.
A quick way to build front-end dependencies is to add post-install-cmd to
your project’s composer.json
file. The post-install-cmd
must contain
the commands that must be executed to build your front-end dependencies.
For example, in composer.json
:
"post-install-cmd": [
"cd docroot/themes/custom/<my_theme> && rm -rf node_modules && npm install && npm run build"
]
An advantage of wrapping your commands in a Composer script is that you can easily run the command during a job, and also within your IDE.
For example, in composer.json
:
"scripts": {
"build-theme": ["cd docroot/themes/custom/<my_theme> && rm -rf node_modules && npm install && npm run build"]
}
For example, in .gitlab-ci.yml
:
"Test Drupal":
before_script:
- composer run-script build-theme
In this example, the front-end theme is built before the Test Drupal job, and will be included in the artifact pushed to Acquia Cloud.
When you need to build theme dependencies, you can run
composer run-script build-theme
in an IDE.
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.
Run the following command to add BLT:
composer require acquia/blt
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
Commit and push your changes.
Code Studio now uses BLT in AutoDev Ops.