All Products
Search
Document Center

CloudOps Orchestration Service:Git deployment

Last Updated:Jun 04, 2026

Deploy applications from a Git repository to ECS instances or ESS scaling groups.

How it works

Important
  • If you deploy to an Auto Scaling (ESS) group, scaling activities are paused during the deployment. They resume automatically after the deployment finishes, whether it succeeds or fails.

  • The deployment process follows a stop-then-start principle. Each deployment first runs the stop script and then runs the start script.

  1. Create and publish a deployment.

    Configure a deployment with your application's source file information, start script, and stop script.

    Create a release task, select a release mode, and publish the deployment to the target application group.

  2. The automated deployment process.

    1. Retrieve deployment information: Git repository details and start/stop scripts.

    2. Pull code from the specified branch into the code_deploy_application folder in the working directory.

    3. Run the stop script to stop the current application.

    4. Run the start script to launch the new application version.

Usage notes

  • Only Linux instances are supported.

  • Start and stop scripts must be Shell scripts.

Procedure

  1. Create an application and import an ECS instance.

    1. If you do not have an ECS instance, create a Linux instance with a public IP address on the ECS console - Custom Launch page.

      Recommended images: Alibaba Cloud Linux 3.2104 LTS 64-bit or Ubuntu 22.04 64-bit. The sample scripts target these images. Modify the scripts if you use a different image.
    2. Go to the ECS console - Application management page and click Create from Existing Resources to create an application and an application group, and import the ECS instance into the application group.

  2. Create a deployment.

    1. Fork the sample code to your Git repository.

      Requires a Gitee or GitHub account. Use Gitee for instances in the Chinese mainland.
    2. Go to the ECS console - Application management page. On the My Applications tab, click the name of your target application.

    3. On the application details page, select the Deployment tab, and then click Create Deployment.

    4. On the Create Deployment page, set RevisionType to Git Repo, configure the parameters, and then click OK.

      • Git repository information: Specify the repository that stores your code.

        On first use, follow the on-screen instructions to authorize Git repository access.
      • Working directory: The directory where start and stop scripts run. Example: /root/deploy. Code is pulled to the code_deploy_application folder in this directory.

      • Application start script:

        Alibaba Cloud Linux

        # Note: The code is downloaded to the code_deploy_application folder within the working directory.
        
        # Start the current version of the application.
        start_application() {
         cd ./code_deploy_application
         set -e
         yum install -y maven-3.5.4
         java -jar sample-spring-1.0-SNAPSHOT.jar &
        }
        
        start_application

        Ubuntu

        # Note: The code is downloaded to the code_deploy_application folder within the working directory.
        
        # Start the current version of the application.
        start_application() {
         cd ./code_deploy_application
         set -e
         apt update
         apt install -y maven
         java -jar sample-spring-1.0-SNAPSHOT.jar &
        }
        
        start_application
      • Application stop script:

        # Stop the application, if it is running.
        stop_application() {
          PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}')
          if [ -n "$PID" ]; then
            kill -9 $PID
          fi
        }
        
        stop_application
  3. Go back to the deployment list, find the deployment that you created, and click Deploy. Select the target group and click OK to start the deployment.

  4. Verify the result.

    1. Navigate to the details page of the target instance. Click Connect and select Workbench. Follow the on-screen prompts to access the terminal.

    2. Run the curl http://localhost:8080/hello command. A response of Alibaba Spring Sample! indicates a successful deployment.

Key parameters

Parameter

Description

Platform

Select the Git platform where your code is hosted.

Owner

Select the repository owner. Authorization is required on first use.

Organization

Select a personal or organization repository.

Repository

Select the code repository.

Branch

Select the branch to deploy.

CommitId

Auto-populated. The system retrieves the latest CommitId after you select a branch.

Working directory

The directory where start and stop scripts run.

  • Enter an absolute path.

  • Code is pulled into the code_deploy_application folder in this directory.

  • Non-existent directories are created automatically.

Application start script

Shell script to start the application.

Application stop script

The shell script to stop the application.
This script must correctly stop both the current and previous application versions. It must also exit gracefully if the application is not running.

For example, the following script stops a container named my-container. This script assumes all container versions share the same name and does not report an error if the container does not exist:

container_name="my-container"
container_id=$(docker ps -aq -f name=${container_name}) 
if [ -n "$container_id" ]; then
  docker rm -f $container_id
fi