Generating a Software Package and Deploying It on a Host Through CodeArts Pipeline
CodeArts Pipeline is a visualized and automated job scheduling platform. It needs to be used together with automated jobs of services such as CodeArts Build, CodeArts Check, CodeArts TestPlan, and CodeArts Deploy. You can orchestrate these automated jobs as needed. A single configuration triggers executions repeatedly to avoid inefficient manual operations.
In this section, we will create a pipeline to sequentially run code checks, build the software package, and deploy it on a host.
Prerequisites
- You have enabled and authorized CodeArts Pipeline.
- You need to prepare a host with an EIP. You can use an existing host or purchase a Huawei Cloud ECS.
Preparations
- Create a project
- Log in to the Huawei Cloud console.
- Click in the upper left corner of the page and choose from the service list.
- Click Access Service to access the CodeArts Pipeline homepage.
- On the top navigation bar, click Homepage. On the displayed page, click Create Project, select Scrum, and enter a name Project01.
- Click OK.
For details, see Creating a Scrum Project and a Work Item.
- Create a code repository and a code check task.
- Click the created project to access it, choose Code > Repo from the left navigation pane.
- Click New Repository, select Template, and select the Java Maven Demo template.
- Click Next and enter the repository name Repo01.
A code check task with the same name as the code repository is automatically created. Change the task name to CheckTask01 by referring to Creating a Task.
- Click OK.
For details, see Creating a Repository Using a Template.
- Create a build task
- In the left navigation pane, choose CICD > Build.
- Click Create Task and configure task information.
- Enter a name BuildTask01, select the code source Repo, select the created repository, select the default branch master, and click Next.
- Select the system template Maven, click OK. On the displayed Build Actions tab page, retain the default configurations.
- Click Save.
For details, see Creating a Build Task.
- Create an application
- In the left navigation pane, choose , create a host cluster, and add the purchased host to the cluster.
- In the left navigation pane, choose CICD > Deploy.
- Click Create Application. On the displayed page, enter an application name DeployTask01, click Next, select Blank Template, and click OK.
- On the Deployment Actions tab page, add the Select Deployment Source action and configure the following information.
- Source: Set the source to Build task
- Environment: Click Create. On the displayed Environment Management page, click Create Environment to import the host to the environment.
- Build task: Select the created build task.
- Download path: Enter the deployment directory of the host. In this example, the directory is /usr/local/.
- Retain default settings for other parameters.
- Click Save.
For details, see Creating an Application with a Blank Template.
Create a pipeline
- Access the created project, choose CICD > Pipeline from the left navigation pane.
- Click Create Pipeline and configure pipeline information.
- Configure the following information and click Next.
Table 1 Pipeline basic information Parameter
Configuration
Name
Enter Pipeline01.
Code Source
Select Repo.
Repository
Select the created repository.
Default Branch
Select master.
- Select Blank Template and click OK.
- Configure the following information and click Next.
- On the Task Orchestration page, two stages (Code Source and Stage_1) are generated by default. Click Stage to add a new stage (Stage_2).
- Add a code check task
- Click New Job under Stage_1.
- Click the Check type and search for the Check extension.
- Move the cursor to the extension, click Add, select the created code check task, and set Check Mode to Full.
Figure 2 Adding a code check task
- Add a build task
- Click Parallel Job under Stage_1, or click under the code check job.
The code check job and build job can be in parallel or serial.
- Click the Build type and search for the Build extension.
- Move the cursor to the extension, click Add, select the created build task, and select the repository associated with the build task.
Figure 3 Adding a build task
- Click Parallel Job under Stage_1, or click under the code check job.
- Add an application
- Click Job under Stage_2.
- In the displayed dialog box, search for the Deploy extension.
- Move the cursor to the extension, click Add, select the created application, and associate it with the added build task.
Figure 4 Adding an application
- Add a code check task
- After the configuration, click Save.
Executing a Pipeline
- Return to the pipeline list page and click in the Operation column.
- In the displayed dialog box, retain the default settings, and click Execute.
- Click the pipeline name to go to the Execution History page.
- Click the execution message to check pipeline execution situation in real time.
Click a job card to view its log.
Checking the Pipeline Execution Result
- Click the avatar in the upper right corner.
- Click CodeArts Console.
- Click in the upper left corner and search for Elastic Cloud Server. Then, access the Elastic Cloud Server console.
- Locate the ECS used for deployment, click Remote Login in the Operation column.
- In the Other Login Modes area, select Log in using Remote Login on the management console and click Log In.
- Enter the username and password for purchasing the ECS. Press Enter.
- Enter the following command and press Enter to go to the directory /usr/local configured during application creation.
cd /usr/local
- Enter the following command and press Enter to check the deployed package.
ls -al
Figure 5 Checking the pipeline execution result
Related Information
CodeArts Pipeline provides built-in templates for you to quickly create pipelines. For more information, see Managing Pipeline Templates.
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