All Products
Search
Document Center

CloudOps Orchestration Service:Build a software package and upload it to OSS

Last Updated:Apr 09, 2025

This sample template describes how to pull code from GitHub, build a software package, and upload the package to Object Storage Service (OSS). You can use this template to build a software package for an existing Elastic Compute Service (ECS) instance. You can also use this template to build a software package for a temporary ECS instance that will be released after the build is complete.

Prerequisites

Sample template

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

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

Example

Prepare the code source

The sample code of a Spring Boot project is used in this example. The code is uploaded to Gitee and GitHub. If you want to use the code, you must fork the code to your own repository. Code address:

  • Gitee: Sample code (recommended for users in the Chinese mainland)

  • GitHub:Sample code (recommended for users in the Chinese mainland)

Create a template

  1. Log on to the CloudOps Orchestration Service console.

  2. In the left-side navigation pane, choose Automated Task > Custom Template and click Create Template.

  3. Select ACS-ECS-ExampleSoftwarePacakgeBuildFromGit and click Next Step.

  4. On the Process Configuration tab, set the parameters and click Create Template.

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

      In this example, Gitee is used as the code source. Set the following parameters: Owner, Organization, Repository, and Branch.

      Note
      • If Alibaba Cloud is not authorized to access your GitHub or Gitee repository, click Grant the required permissions.

      • If you have forked the sample code, all repositories that belong to your account are automatically displayed in the Repository drop-down list. In this case, select the repository to which you forked the code.

      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.

        oss.png

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

        • Choose Building Ecs: Select an ECS instance. You can select Existing ECS or New ECS.

          Note

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

        • Build Configuration: provides build commands as needed.

          If you execute this sample template, Maven will be first installed and a JAR package will be created. The JAR package is in the target directory. You can replace the sample with a script that meets your requirements.

          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 build name.

        In the following example, the package path is target/. OOS will compress the package into a .tgz file.

        构建物.png

    3. Upload the build output to OSS.

      Specify the OSS bucket and object path to which you want to upload the software package.

      screenshot_2024-12-18_14-46-17.png

    4. 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 Template.

  3. On the Custom Template page, find the template and click Create Execution in the Actions column.

  4. In the Basic Information step, set the parameters and click Next Step: Parameter Settings.

  5. In the Parameter Settings step, click OK if no parameters are available.

  6. Click Create.

    On the Task Execution Management page, if the execution status is Success, the execution is complete.

    执行模板结果-zh.png

  7. Log on to the OSS console. Find the specified bucket and path to view the uploaded software package.

    OSS文件列表.png

What to do next

If your code is updated, you need to only push the code to the corresponding GitHub repository and execute the template again. Then, OOS pulls the latest code from the code source and pushes the software package to OSS. If you want to modify the template, you can modify the template and then execute the template.