CD Environments

Tutorial Goal

Lesson Goal:

In this lesson, we will modify a build file so that Acquia CD pipelines will automatically create a new CD environment for each pull request. This environment can then be visited by team members using a web browser to manually test for quality and stability. Once this feature branch is merged, Acquia CD pipelines will destroy the CD environment automatically.

In order to complete this lesson you will need:

Note: GitHub is not a requirement for Acquia Cloud CD.  

In this lesson we will:

  1. Modify your build file
    • Create a new local feature branch
    • Add a new build step
    • Add new pr-merged and pr-closed steps
  2. Submit a Pull Request on GitHub
  3. Visit the new CD environment
  4. Merge the pull request

2. Modify your build file

Create a new local feature branch

Use git to create a new feature branch.

git checkout -b pipelines-ode-deploy

Add a new build step

Next, we will modify your acquia-pipelines.yml file such that a new CDE will be created when a new Pull Request is opened. To accomplish this, we use the Pipelines Deploy tool.

Add the following build step to your build definition file:

     - deploy:
          script:
            - pipelines-deploy

Note: Nest this step under events.build.steps. Please see the acquia-pipelines.yml example.

Add new pr-merged and pr-closed steps

These steps will destroy the CD environment after a pull request is merged or closed:

  pr-merged:
    steps:
      - deploy:
          script:
            - pipelines-deploy

  # When a GitHub pull request is closed, this deletes the coresponding ODE.
  pr-closed:
    steps:
      - deploy:
          script:
            - pipelines-deploy

Note: Nest this step under the events key. Please see the acquia-pipelines.yml example.

Commit the changes and push the feature branch to github remote:

git add acquia-pipelines.yml
git commit -m 'Adding ODE deployment step to acquia-pipelines.yml.'
git push github pipelines-ode-deploy

3. Submit a Pull Request on GitHub

Use the GitHub UI to create a new Pull Request:

Creating a new pull request

A pipelines build is automatically triggered.  Wait for the build to finish and use GitHub to review proposed code changes. 

Once the build completes successfully, a green checkbox appears next to the commit ID. This indicates that all steps were successful, including the step that created the CD environment.

4. Visit the new CD environment

Use the Acquia Cloud UI to find and visit that environment.

Feel free to interact with the application to manually inspect the environment as a user. 

5. Merge the pull request

At this point, you can confidently merge the pull request.

Click the merge button in the GitHub UI. This destroys the CD environment and triggers a pipelines build for the “master” branch, which the feature branch was merged into.

The pipelines-master-build will update on the Acquia Cloud.

You may deploy the pipelines-master-build to a development environment and visit it! 

Congratulations, you’ve successfully implemented a basic continuous integration process with Acquia Cloud!

 

Getting Started with Acquia Cloud CD

  1. Installing CD pipelines client Locally
  2. Defining a Build
  3. Integrating GitHub
  4. CD Environments

Contact supportStill need assistance? Contact Acquia Support