Work with an environment per feature branch¶
Give every feature branch its own environment. Developers, testers and the client can review a change in isolation before it reaches the shared staging environment, and you remove the environment when the branch is merged.
When should I use this pattern?¶
- Several developers work on the same project at the same time.
- A client or product owner needs to review a feature before it is merged.
- You want to test risky changes, such as a Drupal core update or a new module, without blocking staging.
Before you start¶
- Role: you need the Architect role, or equivalent permissions, to create and delete environments.
- Development server: a shared development server supports up to 2 environments per project. To create an environment per branch, you need a dedicated development server. Environments on a dedicated server share its resources, so plan how many branches you keep open at once. See DevOps Feature set for the comparison.
- Deployment method: this pattern works with both the Git reference and the Artifact deployment method. With the Artifact method, the default pipelines already build a package for every branch that has a merge request.
How do I set up an environment for my branch?¶
- Push your branch to your project's GitLab repository, for example
feature/1234-new-header. - Create a new environment in the Environments tab of your project. Name it after the branch so everyone can see what it contains, and add the ticket or feature in the description. See Create a new environment.
- If your project uses scaffolding, the files in
.dropsolid/scaffold/__templatesare copied to the new environment automatically. Keep that folder up to date and new environments work from the first deployment.
- If your project uses scaffolding, the files in
- Deploy your branch to the new environment. See Deploying your application.
- Git reference: enter the branch name.
- Artifact: select the package for your branch.
- Copy content into the environment by syncing the database and files from staging or production. See Sync database or files between environments of a project.
- Syncing from production? Sanitize personal data on the way. See Sanitize your database when syncing between environments.
How do I share the environment for review?¶
- Turn on password protection for the environment in one click, so only reviewers can open it.
- Share the environment URL with your reviewers.
How do I update the environment after new commits?¶
Deploy the branch again. With the Artifact method, each new pipeline on the branch replaces the branch package with the latest version, so you always deploy the most recent build.
How do I clean up after merging?¶
- Merge the branch into your main branch through a merge request.
- If you want a restore point, take a snapshot first. See Taking a Snapshot of an Environment.
- Delete the environment from its Actions menu. This frees the resources on your development server for the next branch.
Can I create and remove these environments automatically?¶
Yes, on the Enterprise tier. Everything in the Platform interface is also available through the Platform API, so a GitLab CI job can create, deploy and delete an environment when a merge request opens or closes. The API documentation is currently available to Enterprise clients. Ask your Dropsolid contact person for access.