Information for:

# Code workflows with Acquia Cloud¶

The Code elements of the Acquia Cloud Environments page provide a user interface for deploying code from your repository to your application’s environments. When you commit a branch to your repository, Acquia Cloud updates the environment running that code branch.

Make and test changes to administrative configurations, views, and other major application settings only in your non-production environments. Don’t make or test changes in your Production environment. If you make a change that breaks your application in the Production environment, your live application may become unavailable.

Complete the following steps when you’re ready to deploy code to an environment:

1. Check out your repository to your local machine.

2. Make changes to your application in the /master directory, or whatever branch you’ve configured to deploy for the Development environment. Any environment deploying a branch will deploy all commits to that branch immediately.

Never deploy the master branch on your Production environment; code committed to master would then deploy immediately in your live application, before you have had a chance to test it.

3. To change the code on your servers, select one of the following methods:

• Commit changes to the currently deployed branch.
• Select a different repository branch or tag to deploy.
4. Deploy your code, either in the same environment or between environments.

5. After you release new code to an environment, perform any pending database updates by visiting http://[site_URL]/update.php in your browser to view scheduled database changes, which are common after core or contributed module updates. Performing these database updates will also clear your application’s caches. If you are uncertain if Drupal’s caches were cleared, Acquia recommends clearing them manually to make sure you are starting from a clean state.

6. After clearing Drupal’s caches, clear the Varnish cache. Be cautious about clearing caches on a production environment under load, and perform Varnish cache clears during times of less user demand.

## Deploying code in the same environment¶

You can deploy a different branch or tag in the same environment from either the Environments page, or from the Environments overview page.

### Deploying code from the Environments page¶

To switch the code deployed in an environment from one tag or branch to another, using the Environments page:

1. In the Code element for the environment, click the code switch button.

2. In the Switch code dialog box, select a tag or branch from the Select branch menu and click Continue.

3. In the Switch code confirmation dialog box, click Switch.

When you select a new branch or tag to deploy, Acquia Cloud retrieves code from your repository and deployed to the appropriate environment on the web servers. The deploy task appears in the Activity task list.

### Deploying code from the Environment Overview page¶

You can deploy code on an environment or copy code from one environment to another using the Overview page of an environment. To switch the code deployed in an environment from one tag or branch to another, using the Overview page:

1. On the Environments page, click the name of the environment to open that environment’s Overview page.

2. On the Overview page for the environment, click Switch.

3. In the Switch code dialog box, select a tag or branch from the Select branch menu and click Continue.

4. In the Switch code confirmation dialog box, click Switch.

Important

Symlinking your docroot directory to any other directory will cause code deployments to fail. For more information about symlinks, see Adding flexibility to your server structure using symlinks.

## Moving code from one environment to another¶

To move code from one environment to another, such as Dev to Stage or from Stage to Prod, use one of the following processes, depending on your location in the Acquia Cloud interface:

• From the Environments page

1. Drag a Code element from one environment to another environment. Acquia Cloud creates a new tag for the head version of the branch (the most recently committed code version) and then deploys the tag in the environment you selected. For example, drag your Dev Code element to Stage.
2. Optionally, you may add a commit message.
3. Click Deploy.

When you drag your Dev code container to the Stage environment, Acquia Cloud creates a symbolic link between the Staging environment and the head version (the most recently committed code version) of trunk in your Development environment. When you click Deploy, Acquia Cloud creates a tag and updates the web server to that version of your code. The default tag format is yyyy‐mm‐dd.version (for example, tags/2016‐09‐18). From the example, the next tag you create would be 2016‐09‐18.0.

When you have a version ready to deploy to your live production application, drag your code element from the Stage environment to Prod. If the Staging environment is running a tag, that same tag is deployed into Production.

• From the Environment Overview page

To copy code from one environment to another (creating and deploying a new tag) using the Overview page:

1. On the Environments page, click the name of the environment to open that environment’s Overview page.

2. On the Overview page for the environment, click Deploy.

3. In the Deploy code dialog box, select the environment from which you want to copy a tag or branch, and then click Continue.

4. In the Deploy code confirmation dialog box, optionally enter a commit message describing the new deployment, and then click Deploy.

## Reverting code¶

To revert code to an earlier version, complete the following steps:

1. In the Code element for the environment, click the code switch button.
2. In the Switch code dialog box, select the tag for the version to which you want to revert, and then click Continue.
3. In the Switch code confirmation dialog box, click Switch.

When you deploy a previous branch or tag, Acquia Cloud retrieves the code snapshot from your repository and then deploys it on the appropriate environment on the web servers.