This topic describes how to configure a pipeline to build HarmonyOS applications.
Instructions
Open the pipeline editing page. For more information, see Open the pipeline editing page.
Click the Build stage area to open the Stage Configuration pane on the right.
In the Stage Configuration pane, configure the following information.
Option
Description
Stage name
Set the name for this stage.
Timeout (minutes)
Set the maximum running time for this stage. The default value is 360 minutes. If the running time of the stage exceeds this value, the stage fails.
Requires a runtime environment
Specify whether this stage requires a runtime environment. A runtime environment is necessary if a build task must run in a specific environment. For example, the build environment contains a configured HarmonyOS SDK and Node.js.
Application build phase: Required
Custom stage (serial scenario): Yes/No
Custom Stage (Parallel scenario): Required
Image
If you set Requires a runtime environment to Yes, the default Image is harmony-latest. If you set this option to No, the Image is Agentless.
Execution condition
Specify the condition for executing this stage.
Execute only when the previous stage succeeds
Execute only when the previous stage fails
Execute unconditionally: The stage runs after the previous stage is complete, regardless of whether it succeeded or failed.
Task steps
Click Add Step to set the tasks for this stage.
In the list of steps that appears, select the steps to add to the Tasks list for this stage and configure them. You can also select existing steps and modify their parameters as needed.
For more information about the configuration, see Use plug-ins to build a custom pipeline.
NoteThe Public switch in the Upload Build Artifact step is turned off by default. When an artifact is made public, you can download it by scanning its QR code in a browser.
Hover over an added task and drag it to change the order of the tasks.
Click OK to save the stage configuration.
Default build steps
Clone code
Clones the code required to build the application from a specified branch of a code repository.
Option
Description
Code address
The default address of the code repository. The code repository is preconfigured. For more information, see Add code access permissions.
Code branch
Set the code branch.
ImportantCase-sensitive.
Access permissions
The default access permissions for the code repository. The access permissions are preconfigured. For more information, see Add code access permissions.
Install certificate
Installs the certificate used to sign the HarmonyOS application in a specified folder.
Option
Description
Certificate folder
Install the certificate to the specified folder in the code. The path is relative to the code root directory.
NoteDefault path: ./sign
p12 certificate
Select a configured p12 certificate.
cer certificate
Select a configured cer certificate.
p7b certificate
Select a configured p7b certificate.
Replace application version
Sets the version number for the application build. If the Replace application version number step is not enabled, the version number from the code is used by default.
Option
Description
versionCode
Set the release version number of the HarmonyOS app.
versionName
Set the release version name of the HarmonyOS app.
bundleName
(Optional) Set the identity of the HarmonyOS app.
Install dependency packages
Installs dependencies based on the oh-package.json5 file of each module.
Option
Description
clean
Clean up before installation.
install
Install dependencies. If a lockfile exists, the versions in the lockfile are installed with priority.
update
Retrieve new versions and install the corresponding dependencies.
Execute build command
Runs a custom shell script.
Option
Description
Script content
Enter a custom shell script. In the HarmonyOS template, the default build command is pre-filled and can be modified.
Script execution directory
Enter the local directory where the custom shell script is executed. If left empty, the code root directory is used by default.
Upload app build artifacts
Collects build artifacts with the .app extension.
Option
Description
Path
Set the relative path from the code root directory to the build artifact storage folder.
NoteSet this option as needed.
Traverse subdirectories
Specify whether to traverse all subdirectories of the specified folder when uploading build artifacts.
File extension
Set the file extension to upload build artifacts of a specific file type. To specify multiple extensions, separate them with commas (,).
NoteIn a HarmonyOS scenario, files with the .app extension are collected by default.
Public
Specify whether the build artifact can be accessed and read by everyone after it is uploaded. This is disabled by default.
NoteIf you are building a debug package, disable this switch.
Upload hap build artifacts
Collects build artifacts with the .hap extension.
Option
Description
Path
Set the relative path from the code root directory to the build artifact storage folder.
NoteSet this option as needed.
Traverse subdirectories
Specify whether to traverse all subdirectories of the specified folder when uploading build artifacts.
File extension
Set the file extension to upload build artifacts of a specific file type. To specify multiple extensions, separate them with commas (,).
NoteIn a HarmonyOS scenario, files with the .hap extension are collected by default.
Public
Specify whether the build artifact can be accessed and read by everyone after it is uploaded. This is disabled by default.
NoteIf you are building a debug package, disable this switch.