Help Center> CodeArts Deploy> Getting Started> Creating a Deployment Task
Updated on 2023-06-29 GMT+08:00

Creating a Deployment Task

This section uses Tomcat as an example to describe how to deploy an application on a host.

Preparations

  • A project is available. If no project is available, create a project first.
  • You have the permission to create applications. For details, see Permission Management.
  • The related software package has been compiled.

    In the deployment action Select a Deployment Source, you can set Source to Software package or Build task. In this example, Software package is selected. Therefore, you need to prepare the compiled software package in advance. If you select Build task, you do not need to prepare the software package.

Procedure

  1. Go to the CodeArts homepage and click the target project name to access the project.
  2. Create basic resources.

    1. Choose Settings > General > Basic Resources. The Host Cluster page is displayed by default.
    2. Click Create Host Cluster, enter the following information, and click Save.

      Parameter

      Mandatory

      Description

      Cluster Name.

      Yes

      Enter a user-defined host cluster name.

      OS

      Yes

      Select Linux or Windows based on the OS of the host to be added.

      Proxy Access

      Yes

      If the target host cannot connect to the public network, you need to select a host bound with an EIP as the proxy host to connect CodeArts to the target host.

      Execution Host

      Yes

      A resource pool is a collection of physical environments where deployment commands are executed during software package deployment. In this scenario, the execution host uses an official resource pool.

      Description

      No

      Description of the host cluster.

    3. (The following uses a target host running Linux as an example.) Click Add Target Host, enter the following information, and click OK.
      Table 1 Parameters of the target host (Linux)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined target host name.

      Proxy Host

      Yes

      Select the target proxy host as the network proxy of the target host that cannot connect to the public network.

      IP

      Yes

      Enter the private or public IP address of the target host.

      OS

      Yes

      Keep the default value because it is the OS of your host cluster.

      Authorization

      Yes

      Select a password or key for authentication as required.

      • Password: The Username and Password are displayed on the page. Take ECS as an example. You need to enter the ECS username and password.
      • Key: The Username and Key are displayed on the page. For details about how to generate and obtain a key, see Obtaining the Linux Key in "Managing Basic Resources" > "Managing Host Clusters" > "Adding and Editing a Host Cluster" in the User Guide.

      SSH Port

      Yes

      Port 22 is recommended. User-defined ports are supported.

    4. Click in the Operation column of a host to start the host for connectivity verification.

  3. Choose CICD > Deploy.
  1. Create an application.

    1. Click Create Application. On the Set Basic Information page that is displayed, modify the basic information such as App Name, Description, and Execution Resource Pool as required.
    2. After editing the basic application information, click Next. The deployment template selection page is displayed.

      Select the template Deploy a Tomcat Application and click OK.

    The following describes the initialization procedure and parameters of the Tomcat application deployment template. For details, see Deployment Actions.

  2. Import basic resources.

    Switch to the Environment Management tab page and click Resources. Click Import Host. The system automatically filters all clusters that meet the requirements of the current environment. In the pop-up box, select the target host cluster and click in the Operation column of a host to import the host to the environment.

  3. Edit an application.

    1. Install JDK.
      Table 2 Parameters for installing the JDK

      Parameter

      Description

      Action Name

      Name of an action displayed in the deployment action.

      Environment

      Target environment.

      JDK Version

      JDK version.

      Installation Path

      Installation path of JDK.

      Action Control

      • Enable this action
      • Continue the task even if this action fails
      • Execute this action with the sudo permission
    2. Install Tomcat.
      Table 3 Parameters for installing Tomcat

      Parameter

      Description

      Action Name

      Name of an action displayed in the deployment action.

      Environment

      Target environment.

      Tomcat Version

      Tomcat version.

      Installation Path

      Installation path of Tomcat.

      HTTP Port

      Default port: 8080

      AJP Port

      Default port: 8009

      Service Shutdown Port

      Default port: 8005

      Action Control

      • Enable this action
      • Continue the task even if this action fails
      • Execute this action with the sudo permission
    3. Stop Tomcat.
      Table 4 Parameters for stopping Tomcat

      Parameter

      Description

      Action Name

      Name of an action displayed in the deployment action.

      Environment

      Target environment.

      Operation

      Start and Stop are available.

      Absolute Path

      Absolute path of the Tomcat service.

      Action Control

      • Enable this action
      • Continue the task even if this action fails
      • Execute this action with the sudo permission
    4. Select a deployment source.
      Table 5 Parameters for selecting a deployment source

      Parameter

      Description

      Action Name

      Name of an action displayed in the deployment action.

      Source

      Two types are available: Software package and Build task.

      Environment

      Target environment.

      Software package

      You can select an existing software package in CodeArts Artifact or from a local host.

      package_url indicates the path of the software package in CodeArts Artifact.

      NOTE:

      Local software packages or files uploaded to CodeArts Artifact can be reused.

      Download Path

      Where the downloaded software package is stored.

      Action Control

      • Enable this action
      • Continue the task even if this action fails
      • Execute this action with the sudo permission

      In this example, Software package is selected as the deployment source. If you select Build task, see Selecting a Deployment Source in the User Guide.

    5. Start Tomcat.
      Table 6 Parameters for starting Tomcat

      Parameter

      Description

      Action Name

      Name of an action displayed in the deployment action.

      Environment

      Target environment.

      Operation

      Start and Stop are available.

      Absolute Path

      Absolute path of the Tomcat service.

      HTTP Port

      HTTP port of the Tomcat service.

      AJP Port

      AJP port of the Tomcat service.

      Service Shutdown Port

      Shutdown port listened by the Tomcat service.

      Waiting Time

      The time required for starting the service. If you set Operation to Start, the system checks the process during startup to determine whether the service is started successfully. You can adjust the time based on the actual time required for starting the service. If the time is improper, the check fails.

      Action Control

      • Enable this action
      • Continue the task even if this action fails
      • Execute this action with the sudo permission
    6. Perform health test through URLs.
      Table 7 Parameters for configuring health test through URLs

      Parameter

      Description

      Action Name

      Name of an action displayed in the deployment action.

      Environment

      Target environment.

      Retries

      The number of times you want the system to retry the health test before the test is considered to have failed.

      Interval (s)

      Test interval.

      Test Path

      Path of the service to be tested. You can add multiple paths.

      Action Control

      • Enable this action
      • Continue the task even if this action fails

      After Health Test Through URLs parameters are set, all parameters are complete. For more configuration details, see Editing an Application in "Managing Applications" > "Editing an Application".

  4. Deploy an application.

    After setting the preceding parameters, click Save and Deploy to deploy an application.
    • Application deployed.

    • If an application fails to be deployed, perform the following steps to locate the fault:
      1. View the automatic matching solution.

        If the deployment fails, click View Solution under deployment actions to go to the corresponding Help Center page.

      2. Search for a solution manually.

        If the issue persists, paste the error information (content in the red box) to the search box of the Help Center and manually search for the solution.

(Optional) Verifying the Deployment Result

The Deploying a Tomcat Application template supports deployment result verification. This section describes how to verify the deployment result for this template. After the application is successfully deployed, enter the following information in the address box of the browser:

<Public IP address of the target host>:8080/tomcat-demo

Press Enter. If the following information is displayed, the application is successfully deployed.