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
An ECS instance is created and the ECS instance can access the Internet. For more information, see Create an ECS instance and Enable Internet access.
ImportantThis sample template supports only the Linux operating system.
OSS is activated and an OSS buckets are created. For more information, see Activate OSS and Create a bucket.
Sample template
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.
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
Log on to the CloudOps Orchestration Service console.
In the left-side navigation pane, choose and click Create Template.
Select ACS-ECS-ExampleSoftwarePacakgeBuildFromGit and click Next Step.
On the Process Configuration tab, set the parameters and click Create Template.
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.
NoteIf 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.

Build a software package such as a JAR package and upload it to OSS.
Select the code source and the ECS instance, and then provide the build command.

CodeResource: In this example,
gitis selected. The output of the previous task is used, which isauthorizedUrl.Choose Building Ecs: Select an ECS instance. You can select Existing ECS or New ECS.
NoteIf 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
targetdirectory. 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 packageSample script (Ubuntu)
### sample build script set -e apt install -y maven mvn packageSample script (CentOS)
### sample build script set -e yum install -y maven mvn package
Provide the package path and build name.
In the following example, the package path is
target/. OOS will compress the package into a.tgzfile.
Upload the build output to OSS.
Specify the OSS bucket and object path to which you want to upload the software package.

Click Create Template.
Execute the template
Log on to the CloudOps Orchestration Service console.
In the left-side navigation pane, choose .
On the Custom Template page, find the template and click Create Execution in the Actions column.
In the Basic Information step, set the parameters and click Next Step: Parameter Settings.
In the Parameter Settings step, click OK if no parameters are available.
Click Create.
On the Task Execution Management page, if the execution status is Success, the execution is complete.

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

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.