Help Center/ CodeArts Build/ Best Practices/ Building with npm and Uploading the Software Package to the Release Repo (Built-in Executors, GUI)
Updated on 2024-11-21 GMT+08:00

Building with npm and Uploading the Software Package to the Release Repo (Built-in Executors, GUI)

Scenario

In this practice, you use built-in executors provided by CodeArts Build to compile a Node.js project and upload the resulting software package to the release repo. These steps will be carried out through the graphical user interface (GUI).

These steps depend on the following services:

Requirements

  • You have permissions for CodeArts Artifact.
  • You have permissions for CodeArts Repo.

Procedure

Table 1 Steps

Step

Description

Creating a Project

Create a project.

Creating a CodeArts Repo Repository

Create a CodeArts Repo repository.

Creating a Build Task

Create a build task.

Configuring Build Actions and Running the Build Task

Configure build actions and run the build task.

Viewing and Verifying the Build Results

View and verify the build results.

Creating a Project

  1. Log in to the Huawei Cloud console with your Huawei Cloud account.
  2. Click in the upper left corner and choose Developer Services > CodeArts from the service list.
  3. Click Access Service. The homepage of CodeArts is displayed.
  4. Click Create Project, and select the Scrum template.
  5. Set the project name to build-bestpractice, and leave the other parameters as default.
  6. Click OK to access the project.

Creating a CodeArts Repo Repository

  1. In the navigation pane, choose Code > Repo.
  2. Access CodeArts Repo, click New Repository. On the displayed page, select Template, and click Next.
  3. On the template selection page, select the Nodejs Webpack Demo template and click Next.
  4. On the repository creation page, type nodesource in the Repository Name field, leave the other parameters as default, and click OK.

Creating a Build Task

  1. In the navigation pane, choose CICD > Build.
  2. Click Create Task. On the displayed Basic Information page, set parameters according to Table 2. Then, click Next.

    Table 2 Basic information

    Parameter

    Description

    Name

    Assign a custom name to the build task, for example, npm_yml_build.

    Code Source

    Select Repo.

    Repository

    Select nodesource, the code repository created in Creating a CodeArts Repo Repository.

    Default Branch

    Keep the default value master.

    Description

    Enter additional information to describe the build task.

  3. Select the npm template and click OK. The Build Actions page is displayed.

Configuring Build Actions and Running the Build Task

  1. Configure action Build with npm.

    In the command editor, add # before the npm run build command. Then add the zip -r ./nodeserver.zip ./ command to pack the code into nodeserver.zip, as shown in Figure 1. Leave the other parameters as default.

    Figure 1 Command example

  2. Configure action Upload to Release Repo according to Figure 2.

    Figure 2 Configuring the action of uploading a software package to the release repo

  3. Once you have finished configuring all build actions, click Save and Run to run the build task.

Viewing and Verifying the Build Results

In the navigation pane, choose Artifact > Release Repos. On the displayed page, find the uploaded software package, as shown in Figure 3.

Figure 3 Checking the uploaded the software package

The package name and release version are the same as those configured in 2.