Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ CodeArts/ Getting Started/ Deploying a Code Development Pipeline on ECS

Deploying a Code Development Pipeline on ECS

Updated on 2024-11-13 GMT+08:00

This section describes how to use the built-in code repository of CodeArts to develop, build, and deploy projects for continuous delivery.

This chapter uses Elastic Cloud Server (ECS) for traditional software package deployment.

To use container-based deployment, see Deploying a Code Development Pipeline on CCE.

Preparations

  1. You have signed up for Huawei Cloud. If you do not have a HUAWEI ID, create one by referring to Registering a HUAWEI ID and Enabling Huawei Cloud Services.
  2. You have purchased an ECS. The following table lists the mandatory configurations. You can select the configurations that are not listed in the table based on the site requirements. After the purchase is complete, add inbound rules for ports 22 and 8080 by referring to Configuring Security Group Rules.
    Table 1 Configuring ECS

    Category

    Parameter

    Suggestion

    Basic Settings

    Billing Mode

    Select Pay-per-use.

    Instance

    CPU Architecture

    Select x86.

    Specifications

    Select 2 vCPUs and 4 GiB or higher.

    OS

    Image

    Choose Public image > CentOS > CentOS 7.6 64bit(10GiB).

    Public Network Access

    EIP

    Select Auto assign.

    Billed By

    Select Bandwidth.

    Instance Management

      

    Login Mode

    Select Password.

    Password

    Enter a password.

Enabling CodeArts Free Edition

  1. Go to the Buy CodeArts page.
  2. Select Free, read and agree to the statement, and click Subscribe.
  3. Check the subscription record on the CodeArts page.

Creating a Project

A project is the basis for using services on CodeArts. Subsequent operations can be performed only after a project is created.

  1. Click Access Service on the CodeArts console.
  2. Click Create Project, select Scrum, enter the project name Demo, and click OK.

Creating a Code Repository

You can use a code repository to manage project code versions. This section describes how to use the built-in template Java Web Demo to create a code repository.

  1. In the navigation pane, choose Code > Repo.
  2. Click New Repository, select Template, and click Next.
  3. On the page displayed, select Java Web Demo and click Next.
  4. Enter the code repository name Web-Demo and click OK.

Checking Code

You can use CodeArts Check to perform static code check and control code quality.

  1. In the navigation pane, choose Code > Check. The automatically created task Web-Demo-check is displayed on the page.
  2. Click in the row where the task is located to start the task.
  3. When is displayed, the task is successfully executed. Click the task name, go to the Overview tab page, and view the check result.

    If the task fails, check and fix errors based on the message displayed on the page.

Building and Archiving Software Packages

You can use CodeArts Build to compile the source code of the software into a target file, packs the configuration file and resource file, and archives them to a release repo.

  1. In the navigation pane, choose CICD > Build. The automatically created build task Web-Demo-build is displayed.
  2. Click in the row where the task is located to start the task. If a dialog box is displayed, confirm the parameter settings and click Confirm.
  3. When is displayed, the task is successfully executed. Click the task name. On the Build History page that is displayed, find the Build ID of the latest build in the list and record the ID.

    If the build fails, rectify the fault based on the failed action information and error information in logs.

    Figure 1 Build ID

  4. Choose Artifact in the navigation pane and click the Release Repos tab.

    In the repository named after the project, go to the folder named after the build task and the folder named after the build number in sequence to find the generated software package demoapp.jar.

    Figure 2 Viewing the software package

Deploying the Build Package

You can use CodeArts Deploy to deploy software packages in a release repo to a VM and run the software.

  1. Configure the target host.

    1. In the navigation pane, choose Settings > General > Basic Resources.
    2. Click Create Host Cluster, configure the following information, and click Save.
      Table 2 Creating a host cluster

      Parameter

      Suggestion

      Cluster Name

      Enter host-group.

      OS

      Select Linux.

      Host Connection Mode

      Select Direct Connection.

      Execution Resource Pool

      Select Official.

    3. Click Add Host, configure the following information, and click OK.
      Table 3 Adding a host

      Parameter

      Suggestion

      Add Hosts by

      Select Adding IP.

      Host Name

      You are advised to keep this same as the name of an ECS purchased in Preparations.

      IP

      Enter the elastic IP address of an ECS purchased in Preparations.

      Authorization

      Select Password.

      Username

      Enter root.

      Password

      Enter the password set when you purchase the ECS in Preparations.

      SSH Port

      Enter 22.

    4. A host record is displayed on the page. If the Verification Result column shows successful, the host is added.

      If the host fails to be added, check its configuration based on the failure details.

  2. Choose CICD > Deploy from the navigation pane. The automatically created application Web-Demo-deploy is displayed on the page.
  3. Click and choose Edit.
  4. Click the Environment Management tab and configure the host environment.

    1. Click Create Environment, configure the following information, and click Save.
      Table 4 Creating an environment

      Parameter

      Suggestion

      Environment

      Enter demo-env.

      Resource Type

      Select Host.

      OS

      Select Linux.

    2. Click Import Host. In the displayed dialog box, select the host cluster and host configured in 1 and click Import.
    3. A message is displayed, indicating that the import is successful. Close the window.

  5. Click the Deployment Actions tab and configure information.

    • Install JDK: Check that the JDK version is openjdk-1.8.0.
    • Select Deployment Source: Set the parameters based on the following table.
      Table 5 Deployment source configuration

      Parameter

      Value

      Source

      Click Build task.

      Build Task

      Select Web-Demo-build.

      Download Path

      Enter /usr/local/${package_name}/.

    • Stop Spring Boot: When you perform this action for the first time, it fails because no service is running on the target host. To disable this action, click on the action card and choose Disable.
      Figure 3 Disabling "Stop Spring Boot"
    • Health Test via URLs: This action is optional and disabled in this example.

  6. Click the Parameters tab and set parameters by referring to the following table.

    Parameter Name

    Value

    host_group

    Select the environment demo-env added in 4.

    package_url

    This parameter is not required. Click in the same row to delete it.

    service_port

    Enter 8080.

    package_name

    Enter demoapp.

  7. Click Save & Deploy. If a dialog box is displayed, confirm the parameter settings and click OK.

    Wait until is displayed on the page. If the deployment fails, rectify the fault based on the failed action information and error information in logs.

  8. View the deployment result.

    Open a new browser page and enter the access address http://IP:8080/test. IP is the elastic IP address of the ECS purchased in Preparations.

    If the following information is displayed, the deployment is successful.

    Figure 4 Deployment result

Configuring a Pipeline

You can use a CodeArts pipeline to connect code check, build, and deployment tasks. When code changes, the pipeline is automatically triggered for continuous delivery.

  1. Choose CICD > Pipeline from the navigation pane. On the Pipelines tab, the automatically created pipeline Web-Demo-pipeline is displayed.
  2. Click and choose Edit.
  3. On the Task Orchestration tab page, configure the pipeline.

    1. APITest is not involved in this document. Therefore, remove the API test task from the pipeline.

      Click next to the Apitest job. In the dialog box that is displayed, click OK.

      Figure 5 Deleting a job
    2. Click the Deploy job, associate build task Build, and set other parameters based on the parameter settings in Deploying the Build Package.

  4. Click the Execution Plan tab, select Code commit, select master from the branch filter drop-down list.

    Figure 6 Configuring the execution plan

  5. Click Save.
  6. Go to Deploy, edit the deployment actions, and enable Stop Spring Boot.
  7. Go to the code repository and search for and open the TestController.java file.

    Click , change hello world to hello world again, submit the information, and click OK.

    Figure 7 Modifying code

  8. Return to the Pipeline page. You can see that the pipeline is running.

    When is displayed, access http://IP:8080/test again. The following figure shows the access result.

    If the task fails to be executed, check the failure cause. You can open the step details page to view the task logs and rectify the fault based on the logs.

    Figure 8 Pipeline execution result

Follow-up Operations

To avoid incurring unnecessary fees, you can release any unused resources once you have completed this example. The following resources can be released.

Table 6 Releasing resources

Resource

Releasing Method

CodeArts project

Choose Settings > General > Basic Information, click Delete Project, and follow the prompts to delete the project.

ECS

Log in to the ECS console, locate the ECS to be deleted in the list, choose More > Delete, and follow the prompts to delete the ECS.

NOTICE:

Released resources cannot be restored. Exercise caution when performing this operation.

Related Information

The check, build, deployment, and pipeline tasks used in this section are provided by the repo template.

You can create tasks for your own project by referring to the following instructions.

Table 7 Task creation instructions

Service

Method

CodeArts Check

See Creating a Task to Check Code from Repo.

CodeArts Build

See Creating a Build Task.

CodeArts Deploy

See Creating an Application.

CodeArts Pipeline

See Creating a Pipeline.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback