Information for: DEVELOPERS   PARTNERS   SUPPORT

Getting started with Code Studio

Review the prerequisites and complete the following steps to get started with Code Studio:

Prerequisites

The following are the prerequisites for using Code Studio:

The following are the required skills for using Code Studio:

  • Basic knowledge of the command line:
    • For example, changing directories, using drush, and so on.
    • Using git on the CLI. For more information, see git basics.
  • Basic understanding about building and installing Drupal.
  • Familiarity with Cloud Platform or Site Factory.

Important

The documentation assumes that you link Code Studio to your personal Cloud Platform account through an SSH key. This may be considered a security risk. If a person can access your private SSH key in Code Studio, the person will have full access to any Cloud Platform application you have access to.

Acquia recommends creating a test account in Cloud Platform that you use exclusively for testing in Code Studio.

Creating a test account

  1. Create a new test Cloud Platform user account using an email alias, such as jane.doe+codestudio@acquia.com.
  2. Ensure that the new test user is assigned a role with the following permissions:
    • Pull and deploy code, files, or databases to non-production environments
    • Add SSH key to git repository
    • Add SSH key to non-production environments
    • Add a CD environment
    • Delete a CD environment
    • Manage environment variables on a non-production environment

For more information on Cloud Platform user roles and permissions, see About Cloud Platform permissions.

Creating a Code Studio project

You can accomplish either of the following using the Setting up a Code Studio project instructions:

  1. Create and configure a new Code Studio project for your Cloud Platform application.
  2. (Re)configure an existing Code Studio project for your Cloud Platform application.

By completing these instructions, you have a Code Studio with an AutoDevOps pipeline that automatically:

  • Builds, tests, and deploys your Drupal application for each commit.
  • Builds, tests, stages, and deploys your Drupal application for each merge request.
  • Performs scheduled pipelines to automatically update your Composer packages and deprecated custom code.

Setting up a Code Studio project

  1. Create an Acquia Cloud IDE for your Cloud Platform application.

  2. Launch the Cloud IDE.

  3. If you already have a Drupal application code on Cloud Platform, select Configure IDE and Copy Code From Cloud Platform.

    To create a new Drupal application, run the acli new command and select acquia/drupal-recommended-project.

  4. Generate a personal access token in Code Studio by performing the following steps:

    1. Log in to Code Studio.

    2. In the top right corner, click your profile icon.

    3. Click Edit profile.

      The system displays your user settings.

    4. Click Access Tokens.

    5. In the Add a personal access token section, provide the required details to create a new personal access token for authenticating with Code Studio.

    6. In Name, enter a name for the token.

    7. In Selected Scopes, select the api and write_repository checkboxes.

    8. Click Create personal access token.

      Code Studio creates your new personal access token and displays it on the screen.

    9. Copy your new token.

Important

You must save your personal access token as you cannot access it again.

  1. Run the following command to authenticate with Code Studio:

    glab auth login
    
  2. Select HTTPS when prompted.

  3. Run the following commands to create and/or configure a Code Studio project for your Cloud Platform application:

    acli update
    acli cs:wizard
    

    The ACLI command walks you through the following process:

    • (prompt) Creating an API token for Code Studio
    • (automated) Creating an SSH key for Code Studio
    • (automated) Setting GitLab CI/CD variables
    • (automated) Creating a scheduled pipeline for automatic updates
    • (automated) Pushing your Cloud Platform application code to Code Studio

Note

Cloud Platform sends an email to your user account notifying that an SSH key labeled CODESTUDIO_+key is added to your Acquia account. This is a normal, expected, and secure email that serves as a notification.

Pushing Drupal application code into your Code Studio project

Requirements:

Use one of the following options to continue the process of pushing Drupal application code into your Code Studio project:

Option 1: Use an existing Drupal Application repository

Requirements:

  • You must use a Drupal 8+ site.
  • You must use Composer to manage your application dependencies.
  • You must clone a copy of your Drupal code on your local machine or Cloud IDE.

To push an existing Drupal application repository into Code Studio:

  1. Navigate to your Drupal project directory on your local machine or in a Cloud IDE:

    cd <git repository path on your local machine or Cloud IDE>
    
  2. Push to Code Studio:

    git remote add codestudio http://code.acquia.com/[gitlab-group]/[gitlab-project-name].git
    
    git push codestudio <enter branch name>
    

Option 2: Generate a new Drupal application repository with Acquia CLI

To generate a new Drupal application repository:

  1. Run the acli new command and select acquia/drupal-recommended-project.
  2. Navigate to your new directory by running the cd <directory name> command.
  3. To use BLT, see the Using BLT section.
  4. Follow the directions to use an existing Drupal Application repository.