All Products
Search
Document Center

CloudOps Orchestration Service:Local build and deploy

Last Updated:Jun 22, 2026

Pull code from a Git repository and use CloudOps Orchestration Service (OOS) to build and deploy an application on a single ECS instance.

Note

This sample template builds and deploys an application locally on a single ECS instance. If you need to publish a build artifact to a repository or deploy it to multiple ECS instances, see the following topics: Build an image and upload it to Container Registry, Build an image, upload it to Container Registry, and deploy it, Build a software package and upload it to OSS, and Build a software package, upload it to OSS, and deploy it.

Prerequisites

Template workflow

image
  1. You specify a code source, such as OSS or Git. OOS then generates a temporary authorization link for pulling the code.

  2. OOS automatically pulls the code and runs a script to build and deploy the application.

Example

Prepare the code source

This example uses a sample Spring Boot project. The code is available in Gitee and GitHub repositories. Before you start, fork the project to your own repository.

Create a template

  1. Log on to the CloudOps Orchestration Service console.

  2. In the left-side navigation pane, choose automated task > custom task template, and then click Create Template.

  3. In the Building and Deployment section, select local build and deploy, and then click Next.

  4. On the Process Configuration tab, configure the template parameters, and then click Create Template.

    1. Specify a code source to generate a temporary authorization link for pulling the code.

      This example uses Gitee as the code source. Enter the Owner, Organization, repository, and branch for your repository.

      Note
      • If you have not authorized Alibaba Cloud to read your repositories from GitHub or Gitee, click Go to Authorization to grant access.

      • If you have already forked the sample code, your repositories are automatically listed in the repository drop-down list. Select the forked repository.

      2024-12-16_11-42-41.png

    2. Pull, build, and deploy the application.

      Select the ECS instance where you want to build and deploy the application. Set the code source to git. The code source URL references the authorizedUrl output from the previous task. A sample build and deployment script is provided below. Replace it with a script suitable for your project.

      部署脚本.png

      Alibaba Cloud Linux 3

      ### Build jar file.
      set -e
      yum install -y maven-3.5.4
      mvn package
      
      ### Stop the previous version of the application (if any) and deploy the current version.
      PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}')
      if [ -n "$PID" ]; then
          kill -9 $PID
      fi
      java -jar target/sample-spring-1.0-SNAPSHOT.jar &

      Ubuntu

      ### Build jar file.
      set -e
      apt install -y maven
      mvn package
      
      ### Stop the previous version of the application (if any) and deploy the current version.
      PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}')
      if [ -n "$PID" ]; then
        kill -9 $PID
      fi
      java -jar target/sample-spring-1.0-SNAPSHOT.jar &

      CentOS

      ### Build jar file.
      set -e
      yum install -y maven
      mvn package
      
      ### Stop the previous version of the application (if any) and deploy the current version.
      PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}')
      if [ -n "$PID" ]; then
        kill -9 $PID
      fi
      java -jar target/sample-spring-1.0-SNAPSHOT.jar &
      Note

      OOS pulls the code to /root/workspace/ExecutionTaskID and runs the build and deployment script from that directory. To use a different path, modify the script accordingly.image

    3. After you configure the parameters, click Create Template.

Execute the template

  1. Log on to the CloudOps Orchestration Service console.

  2. In the left-side navigation pane, choose automated task > custom task template.

  3. On the custom task template page, find the template that you created and click Create an execution in the Actions column.

  4. In the Basic Information step, configure the parameters and click Next: Set Parameters.

  5. In the Parameter Settings step, if no changes are needed, click Next: Confirm.

  6. Click Create.

    On the task execution management page, a status of Successful indicates that the execution is complete.

    执行模板结果-zh.png

  7. Log on to the ECS console.

  8. Find the ECS instance you selected and connect to it remotely.

    For more information, see Log on to a Linux instance by using Workbench.

  9. Run the following command to verify that the deployment succeeded.

    curl http://localhost:8080/hello

    If a hello field is returned, the deployment is successful.image