Using the File from the Self-hosted Repo to Build with Maven and Uploading the Resulting Software Package (Built-in Executors, GUI)
Scenario
CodeArts Build provides default dependency repositories. If they fall short of your service needs, you can create custom repositories for Maven builds.
These steps depend on the following services:
- CodeArts Repo: stores your project code.
- CodeArts Artifact: stores your private dependencies.
Requirements
- You have permissions for CodeArts Artifact.
- You have permissions for CodeArts Repo.
Procedure
Step |
Description |
---|---|
Create a project. |
|
Create a self-hosted repo. |
|
Check the ID and URL of the self-hosted repo, which will be used for configuring the pom.xml file of the code repository. |
|
Upload the settings.xml file to Files for management in CodeArts Build. |
|
Create a code repository. |
|
Configuring the Self-hosted Repo Address for Storing Maven Build Products |
Configure the address of the self-hosted repo where the build product will be uploaded. |
Create a build task. |
|
Configure actions Download File from File Manager and Build with Maven, and run the build task. |
|
View the build results stored in the self-hosted repo. |
Creating a Project
- Log in to the Huawei Cloud console with your Huawei Cloud account.
- Click in the upper left corner and choose from the service list.
- Click Access Service. The homepage of CodeArts is displayed.
- Click Create Project, and select the Scrum template.
- Set the project name to build-bestpractice, and leave the other parameters as default.
- Click OK to access the project.
Creating a Self-hosted Repo
- In the navigation pane, choose .
- Click Create and set parameters according to the following table.
Table 2 Parameters for creating a self-hosted repo Parameter
Description
Repository Type
Select Local Repository.
Repository Name
Assign a custom name to the repository, for example, private_repository.
Package Type
Select Maven.
Project
Leave the value as default. The field is autofilled with build-bestpractice in this practice.
Include Patterns
Leave it blank.
Version Policy
Specify the version of artifacts stored in the repository. Select either Release (the release version with stable functions) or Snapshot (the development version with unstable functions). You can also select both of them if needed. In this practice, select Release.
Description
Enter additional information to describe the repository. Use no more than 200 characters.
- Click Submit. The details page of private_repository is displayed.
Checking Information About the Self-hosted Repo
- Click Tutorial in the upper right corner.
- In the displayed dialog box, click Download Configuration File, leaving the settings as default.
- In the dialog box that appears next, click Download.
Figure 1 Downloading the configuration file
- Open the downloaded settings.xml file and navigate to the <profile> section that includes the <repositories> element. Under this element, find the <repository> block that contains information about the repository. Record the values of id and url.
Figure 2 Checking the repository ID and URL
Uploading the settings.xml File to CodeArts Build
- In the navigation pane, choose .
- On the build task list page, choose .
- On the displayed page, click Upload File.
- In the displayed dialog box, upload the settings.xml file you download when checking information about the self-hosted repo. Select the check box to confirm that you have read and accept the agreements. Then click Save.
Creating a CodeArts Repo Repository
- In the navigation pane, choose .
- On the displayed page, click New Repository. Select Template, and click Next.
- On the template selection page, select the Java Maven Demo template and click Next.
- On the repository creation page, type private_repository_repo in the Repository Name field, and leave the other parameters as default.
- Click OK. Figure 3 shows the directory that stores files of the code repository.
Configuring the Self-hosted Repo Address for Storing Maven Build Products
- Click the pom.xml file to enter its details page. In the right pane, Click to access the file editor.
- Copy the following sample code and add it under the build tag.
Figure 4 Sample code of the pom.xml file
<distributionManagement> <repository> <id>ID</id> <url>https://example/</url> </repository> </distributionManagement>
Replace the placeholders of id and url (ID and https://example/) with the values of id and url recorded in 4.
- Click OK.
Creating a Build Task
- In the navigation pane, choose .
- Click Create Task. On the displayed Basic Information page, set the following parameters. Leave the other parameters as default.
- Name: Assign a custom name to the build task, for example, private_repository_task.
- Code Source: Select Repo.
- Repository: Select private_repository_repo, the code repository created in Creating a CodeArts Repo Repository.
- Click Next. On the displayed page, select Blank Template.
- Click OK. The Build Actions page is displayed.
Configuring Build Actions and Running the Build Task
- Click Add Action. Add action Download File from File Manager. Leave Action Name and Tool Version as default. Expand the File Name drop-down list and select the settings.xml file uploaded to CodeArts Build.
- Click Add Action. Add action Build with Maven. In the Commands window, add a number sign (#) before the mvn package -Dmaven.test.skip=true -U -e -X -B command, delete the number sign before mvn deploy -Dmaven.test.skip=true -U -e -X -B, and change mvn deploy -Dmaven.test.skip=true -U -e -X -B to mvn deploy -Dmaven.test.skip=true -s settings.xml -U -e -X -B. Leave the other parameters as default.
Figure 5 Command for packaging
Figure 6 Command for releasing the dependencies
- Click Save and Run. In the displayed dialog box, click Confirm. Wait for the build task to complete.
Viewing the Build Results
- Click the build task name (private_repository_task is used in this practice).
- On the Build History tab page, click the build ID. On the displayed page, check the action logs. com/huawei/demo/javaMavenDemo/1.0 is the path of the uploaded build product in the self-hosted repo private_repository.
Figure 7 Path for uploading dependencies
- In the navigation pane, choose .
- Expand private_repository and its subfolders. Find the uploaded software package at com/huawei/demo/javaMavenDemo/1.0.
Figure 8 Checking the uploaded the software package
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot