Uploading Software Packages with CMake
Background
CodeArts Build allows you to configure build scripts using YAML files. You can use YAML syntax to compile the build environment, parameters, commands, and steps into a build.yml file, which can be stored in a code repository with the built code. The system uses the build.yml file as the build script to execute the build task, making the build process traceable, recoverable, secure, and reliable. The build with CMake is used as an example in this section.
Prerequisites
A project is available. If no project is available, create one.
Creating a Code Repository
- Log in to CodeArts using the Huawei Cloud account.
- Click the name of the project to create a repository for it.
- In the navigation pane, choose Figure 1. , as shown in
- Click New Repository.
- Set parameters based on Table 1 and click OK.
Table 1 Creating a code repository Parameter
Description
Repository Name
Customize the name for the code repository, for example, CppDemo_build.
- The name starts with a digit, letter, or underscore (_).
- The value can contain periods (.) and hyphens (-).
- The value cannot end with .git, .atom, or a period (.).
Description
Describe the code repository.
.gitignore Programming Language
Select .gitignore based on the programming language, for example, Java.
Permissions
Select all.
- Make all project developers automatic repository members: A project manager is automatically set as the repository administrator, and a developer is set as a common repository member. When the two roles are added to the project, they will be automatically synchronized to existing repositories.
- Generate README: You can edit the README file to record information such as the project architecture and compilation purpose, which is similar to a comment on the entire repository.
- Automatically create Check task (free of charge): After the repository is created, you can view the code check task of the repository in the check task list.
Visibility
Set this parameter to Private.
- Private: Only repository members can access and commit code.
- Public: The repository is open and read-only to all guests, but is not displayed in their repository list or search results. You can select an open-source license as the remarks.
Creating a build.yml File
- In the navigation pane, choose .
- Click the name of the code repository you created (see Creating a Code Repository).
- Choose Figure 2. , as shown in
- Set parameters based on Table 2 and click OK.
- Click the name of the directory created in Step 4.
- Choose Figure 3. , as shown in
- Name the file build.yml and copy the following code to the file:
# This YAML is the default template and can be modified based on this --- version: 2.0 steps: PRE_BUILD: - checkout: name: "checkout" inputs: scm: "codehub" url: "git@codehub.devcloud.cn-north-4.huaweicloud.com:cszl00001/cppDemo.git" branch: "master" lfs: false submodule: false BUILD: - cmake: name: "CMake Build" inputs: command: | # Create the build directory and switch to the build directory. mkdir build && cd build # Generate makefiles for the Unix platform and perform the build. cmake -G 'Unix Makefiles' ../ && make -j - upload_artifact: inputs: path: "build/*" version: 2.1 name: packageName
- Click OK.
Creating a CMakeLists.txt File
Creating a helloworld.cpp File
Creating a Build Task
- In the navigation pane, choose Figure 4. , as shown in
- Click Create Task.
- Set parameters based on Table 3.
Table 3 Basic information Parameter
Description
Task Name
Enter a custom task name, for example, CppDemo_build.
Code Source
Select Repo.
Source Code Repository
Select the code repository you created (see Creating a Code Repository).
Branch
Select the branch created when you create the repository in Creating a Code Repository. If no branch is available, select the default master.
Description
Describe the build task.
- Click Next.
- Select Blank Template and click Next.
- Click the Code tab to view the imported build script, as shown in Figure 5.
- Click Create and Run in the upper right corner.
Viewing and Verifying the Build Result
- In the navigation pane, choose .
- Go to the release repos to view the released software package. The software package name is the same as the task name when you create a build task.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.