Code Studio

Setting up a Code Studio project

For your Cloud Platform application, you can either create and configure a new Code Studio project or reconfigure an existing Code Studio project.

You can connect your Cloud Platform application to your Code Studio project through one of the following:

Connecting your Cloud Platform application with Code Studio

  1. Configure your working environment by using one of the following steps:

  2. Generate a Cloud Platform API token, and make a note of the API key and API secret as you cannot retrieve them after closing your browser tab.

  3. Generate a Code Studio personal access token:

    1. Log in to Code Studio.

    2. In the top left 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.

  4. Authenticate with Code Studio:

    • If you are using a Cloud IDE, run:

      glab auth login --hostname=code.acquia.com
      

      Select HTTPS when prompted.

    • If you are using a local environment, configure the SSH keys for Acquia Platform.

  5. Create and/or configure a Code Studio project for your Cloud Platform application with the following commands:

    acli update
    acli cs:wizard --gitlab-host-name=code.acquia.com
    

    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

    When the setup wizard prompts for the token key and secret, paste the the API key and API secret that you noted while generating the token.

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

Prerequisites:

To push Drupal application code into your Code Studio project, use one of the following options:

Option 1: Pushing code through an existing Drupal application repository

Prerequisites:

  • Use a Drupal site of version 9.x or later.

  • Use Composer to manage your application dependencies.

  • Clone your Drupal code on your local machine or on Cloud IDE.

To push an existing Drupal application repository into Code Studio:

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

    cd <git-repository-path>
    
  2. Add a new remote based on your requirement:

    • To use multiple remotes to manage the repository, add your repository to remote with the name codestudio:

      git remote add codestudio https://code.acquia.com/[gitlab-group]/[gitlab-project-name].git
      
    • To use only Code Studio to manage the repository, add your repository to remote with the name origin:

      git remote add origin https://code.acquia.com/[gitlab-group]/[gitlab-project-name].git
      
  3. Push the code from the project root to Code Studio:

    git add .
    git commit -m "Installed site"
    git push <REMOTE> <BRANCHNAME>
    
  4. Ensure that your development environment has the database and files for the installed site:

    acli push:db
    acli push:files
    

    Code Studio is ready to manage your site.

Option 2: Pushing code through a new Drupal application repository

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. Continue with the steps mentioned in Pushing code through an existing Drupal application repository.