All Products
Search
Document Center

CloudOps Orchestration Service:Build and deploy a package via OSS

Last Updated:Sep 21, 2026

This template pulls code from Git, builds a package, uploads it to Object Storage Service (OSS), and deploys it to multiple Elastic Compute Service (ECS) instances. You can build on an existing ECS instance or a temporary instance that is released after the build.

Prerequisites

Sample template

image
  1. You specify the code source, such as Object Storage Service (OSS) or Git. CloudOps Orchestration Service (OOS) generates a temporary URL to pull code from the specified source.

  2. Build a software package such as a JAR package and upload it to OSS.

  1. Pull the package and deploy it to multiple ECS instances.

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 Build a software package, upload it to OSS, and then deploy it, and click Next.

  4. On the Process Configuration tab, enter the template parameters and 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. Build a software package such as a JAR package and upload it to OSS.

      1. Select the code source and the ECS instance, and then provide the build command.

        • CodeResource: In this example, git is selected. The output of the previous task is used, which is authorizedUrl.

        • Choose Building Ecs: Select Existing ECS or New ECS as the build instance.

          Note

          If you select New ECS, you are charged on a pay-as-you-go basis. OOS checks whether Docker is installed on the instance. If Docker is not installed, OOS installs Docker Community Edition automatically.

        • Build Configuration: Provide build commands as needed.

          This topic provides only a sample build and deployment script. When you run the script, Maven is installed first and then a JAR package is created in the target directory. You can replace the sample script with one that suits your project.

          Sample script (Alibaba Cloud Linux 3)

          ### sample build script
          set -e
          yum install -y maven-3.5.4
          mvn package

          Sample script (Ubuntu)

          ### sample build script
          set -e
          apt install -y maven
          mvn package

          Sample script (CentOS)

          ### sample build script
          set -e
          yum install -y maven
          mvn package
      2. Provide the package path and the build name, which is the name of the package to be created.

        In this example, the package path is target/. OOS compresses the package into a .tgz file.

    3. Upload the build output to OSS.

      Specify the OSS bucket and object path for the package.

      goujianwu --oos.png

      In the Task Output(Optional) section, add bucketName (OSS bucket name) and objectName (full path of the build in the bucket). These outputs can be referenced by subsequent tasks.

    4. Deploy the package to multiple Linux-based ECS instances.

      目标ECS.png

      • Target Instance: Select the ECS instances to deploy the package to.

      • OSS: The bucket name and object name are auto-populated from the previous step. Specify the download directory for the package. This example uses /home/admin/app/.

      • Deployment Script: Provide a deployment script for your application.

        This example decompresses the .tgz file and runs the JAR package on port 8080 with java -jar.

    5. Optional. Configure concurrency control for multi-instance deployment.

    6. 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. Connect to the ECS instance.

    Log on to a Linux instance using Workbench.

  9. Run the following command to verify the deployment.

    curl http://localhost:8080/hello

    If the following message appears, the deployment succeeded.image

    Note

    If you see Failed to connect to localhost port 8080:Connection refused, Java may not be installed. Run yum install java and retry.

What to do next

To deploy updated code, push it to the Git repository and re-execute this template. The latest code is automatically pulled, packaged, uploaded to OSS, and deployed. You can also modify the template before re-execution.