Container-based continuous integration method, device, system, working node and medium

By using container technology to generate and isolate the compilation dependency environment in software development, the efficiency and resource utilization problems of continuous integration tasks are solved, and efficient resource sharing and environment configuration are achieved.

CN114296871BActive Publication Date: 2025-08-19HUMAN HORIZONS (SHANGHAI) CLOUD COMPUTING TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111578302.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-22
Publication Date
2025-08-19
Estimated Expiration
2041-12-22

AI Technical Summary

Technical Problem

In the software development process, in the prior art, due to the different configurations required by different code projects, continuous integration tasks require a lot of time to configure work nodes, which affects execution efficiency and resource utilization.

Method used

Using container technology, we obtain the dependency mirror generation script of the object code project, generate the latest compilation integration image, and compile it in the compilation environment. After the compilation is completed, the workspace is cleared to achieve isolation and resource sharing of the compilation dependency environment.

Benefits of technology

It improves the execution efficiency and resource reuse rate of continuous integration, reduces the cost of environment configuration, and realizes resource sharing for different types of tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114296871B_ABST
    Figure CN114296871B_ABST
Patent Text Reader

Abstract

The present invention discloses a container-based continuous integration method, device, system, working node and storage medium. The method comprises: in response to receiving a continuous integration task for a target code project sent by a task management node, obtaining a dependency image generation script of the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects; generating the latest compilation integrated image of the target code project according to the dependency image generation script; wherein the latest compilation integrated image includes a compilation environment, dependent projects and a compiler for compiling code according to the compilation environment and dependent projects; allocating the latest compilation integrated image to a corresponding compilation workspace, and compiling the target code project in the compilation environment of the latest compilation integrated image; and clearing the compilation workspace after compilation is completed. The present invention can improve the execution efficiency and resource reuse rate of continuous integration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software development, and in particular to a container-based continuous integration method, device, system, working node, and storage medium. Background Art

[0002] During the software development process, developers need to perform continuous integration. To properly execute continuous integration compilation tasks, they need to install and configure the compilation environment, numerous dependent projects, compilation toolchains, and operating systems on worker nodes. However, because different code projects require different configurations, configuring different types of worker nodes for different continuous integration tasks takes a significant amount of time. Furthermore, worker nodes cannot share resources, impacting the efficiency and resource utilization of continuous integration. Summary of the Invention

[0003] Embodiments of the present invention provide a container-based continuous integration method, device, system, working node, and storage medium, which can improve the execution efficiency and resource reuse rate of continuous integration.

[0004] In a first aspect, an embodiment of the present invention provides a container-based continuous integration method, comprising:

[0005] In response to receiving a continuous integration task for a target code project sent by a task management node, obtaining a dependency image generation script for the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects;

[0006] Generate the latest compiled integrated image of the target code project according to the dependent image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code according to the compilation environment and the dependent projects;

[0007] Allocating the latest compiled integrated image to a corresponding compilation workspace, and compiling the target code project in the compilation environment of the latest compiled integrated image;

[0008] After the compilation is completed, the compilation workspace is cleared.

[0009] As an improvement to the above solution, the dependency image generation script further includes a compiled integrated image ID; the configuration information includes installation information and update information;

[0010] Then, generating the latest compiled integrated image of the target code project according to the dependency image generation script specifically includes:

[0011] Obtaining the compiled integrated image corresponding to the target code project from the compiled integrated image repository according to the compiled integrated image ID;

[0012] If the acquisition is successful, the compiled integrated image of the target code project is updated according to the update information to obtain the latest compiled integrated image of the target code project;

[0013] If the acquisition fails, the image is installed according to the installation information to obtain the latest compiled integrated image of the target code project, and the latest compiled integrated image is associated with the compiled integrated image ID and saved in the compiled integrated image warehouse.

[0014] As an improvement to the above solution, the target code project is compiled in the compilation environment of the latest compiled integrated image, specifically:

[0015] The directory of the target code project and the directory of the compilation workspace are used as the compilation code source address and the compilation file output address respectively, and the latest compilation integrated image is started for compilation.

[0016] As an improvement to the above solution, the compiled files include executable files;

[0017] After the compilation is completed and before clearing the compilation workspace, the method further includes:

[0018] The executable file is saved to the release component repository.

[0019] As an improvement to the above solution, the dependency image generation script also includes configuration information of an image generation plug-in; the latest compiled integrated image also includes the image generation plug-in; the image generation plug-in is used to generate a compilation result image corresponding to the executable file;

[0020] The file obtained by the compilation also includes the compilation result image.

[0021] As an improvement to the above solution, before clearing the compilation workspace after the compilation is completed, the method further includes:

[0022] The compilation result image is saved to the release image warehouse.

[0023] In a second aspect, an embodiment of the present invention provides a container-based continuous integration device, comprising:

[0024] a script acquisition module, configured to, in response to receiving a continuous integration task for a target code project sent by a task management node, acquire a dependency image generation script for the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects;

[0025] An image generation module, configured to generate a latest compiled integrated image of the target code project based on the dependent image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code based on the compilation environment and the dependent projects;

[0026] A code compilation module, configured to allocate the latest compiled integrated image to a corresponding compilation workspace and compile the target code project in the compilation environment of the latest compiled integrated image;

[0027] The workspace clearing module is used to clear the compilation workspace after the compilation is completed.

[0028] In a third aspect, an embodiment of the present invention provides a working node, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, any one of the container-based continuous integration methods provided in the first aspect is implemented.

[0029] In a fourth aspect, an embodiment of the present invention provides a container-based continuous integration system, comprising a code repository, a trigger, a master node, and one or more worker nodes provided by the third aspect;

[0030] The code repository is used to receive and store code projects submitted by users;

[0031] The trigger is configured to generate a compilation trigger request for a target code project corresponding to the code change event when a code change event is detected in the code repository, and send the request to the master node;

[0032] The master node is configured to respond to the compilation trigger request, generate a continuous integration task for the target code project, and send the task to any idle worker node.

[0033] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the container-based continuous integration methods provided in the first aspect.

[0034] Compared with the prior art, the container-based continuous integration method, device, system, working node and storage medium provided by the embodiments of the present invention obtain the dependency image generation script of the target code project when receiving the continuous integration task for the target code project sent by the master node to generate the latest compiled integrated image of the target code project, and then allocate the latest compiled integrated image to the pre-built compilation workspace, and compile the target code project in the compilation environment of the latest compiled integrated image to obtain the compiled file, and then clear the compilation workspace. In this way, the compilation dependency environment can be quickly configured using container technology, and the isolation of the compilation dependency environment can be achieved, so that different types of continuous integration tasks can share the resources of the same working node, thereby improving the execution efficiency and resource reuse rate of continuous integration. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a flowchart of a container-based continuous integration method provided by one embodiment of the present invention;

[0036] Figure 2 Schematic diagram of a working node for executing the continuous integration method provided by an embodiment of the present invention;

[0037] Figure 3 It is a schematic diagram of a working node in the prior art;

[0038] Figure 4a and Figure 4b This is a specific flow chart of a container-based continuous integration method provided by an embodiment of the present invention;

[0039] Figure 5 This is a schematic diagram of the structure of a container-based continuous integration device provided by one embodiment of the present invention;

[0040] Figure 6 This is a schematic diagram of the structure of a working node provided by one embodiment of the present invention;

[0041] Figure 7 This is a schematic diagram of the structure of a container-based continuous integration system provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0043] See also Figure 1, is a flow chart of a container-based continuous integration method provided by one embodiment of the present invention.

[0044] The container-based continuous integration method provided in this embodiment includes:

[0045] S11. In response to receiving a continuous integration task for a target code project sent by a task management node, obtain a dependency image generation script of the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects.

[0046] S12. Generate a latest compiled integrated image of the target code project according to the dependent image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code according to the compilation environment and the dependent projects.

[0047] S13: Allocate the latest compiled integrated image to a corresponding compilation workspace, and compile the target code project in a compilation environment of the latest compiled integrated image.

[0048] S15. After the compilation is completed, the compilation workspace is cleared.

[0049] Specifically, dependent projects include internal dependent sources, external dependent sources, and dependent operating systems, wherein internal dependency means that a file inside the code project depends on another file inside the code project, while external dependency means that a file inside the code project depends on another file outside the code project. The dependency image generation script may include an environment variable configuration generation script, compilation computing resource requirement restrictions, the name and version of the operating system that depends on the base image, an internal dependency source setting script, an external dependency source setting script, and the dependency requirements of the dependency image generation script on the operating system environment, so that a compiled integrated image can be generated according to the dependency image generation script. Exemplarily, the dependency image generation script is saved in the root directory of the code project.

[0050] For example, Figure 2 As shown, the execution device of the method provided in this embodiment is a work node, which may be pre-divided into multiple compilation workspaces. Each compilation workspace can load a compilation integration image to compile the code project, so that different types of continuous integration tasks can share the resources of the same work node for compilation. After the compilation is completed, the compilation workspace is cleared, so that another continuous integration task can continue to use the compilation workspace for compilation. Compared with Figure 3The prior art shown in the embodiment provides a container-based continuous integration method, which creates a docker container for compilation by compiling an integrated image, and integrates all compilation environments and dependent projects inside the docker container, so that the compilation dependency environment can be quickly configured using container technology. Moreover, all compilation processes are executed in the image container, which realizes the isolation of the compilation dependency environment and only utilizes the computing and storage resources of the working node. After the compilation is completed, the workspace can be automatically cleared, so that the compilation is independent of the working node configuration, so that different types of continuous integration tasks can share the resources of the same working node, which greatly reduces the environment configuration cost and improves the execution efficiency and resource reuse rate of continuous integration.

[0051] As one of the optional embodiments, the dependency image generation script further includes compiling an integrated image ID; the configuration information includes installation information and update information;

[0052] Then, generating the latest compiled integrated image of the target code project according to the dependency image generation script specifically includes:

[0053] S121. Obtaining the compilation integrated image corresponding to the target code project from the compilation integrated image repository according to the compilation integrated image ID;

[0054] S122: If the acquisition is successful, updating the compiled integrated image of the target code project according to the update information to obtain the latest compiled integrated image of the target code project;

[0055] S123: If the acquisition fails, perform image installation according to the installation information to obtain the latest compiled integrated image of the target code project, and associate the latest compiled integrated image with the compiled integrated image ID and save it in the compiled integrated image warehouse.

[0056] It should be noted that the compilation integration image ID is unique, so that the compilation integration images of different code projects in the compilation integration image warehouse can be distinguished by the compilation integration image ID assigned to each code project.

[0057] For example, when the code changes, the dependency source may be added or reduced, resulting in the need for updating. Therefore, the internal dependency source setting script and the external dependency source setting script may contain installation, update and cleanup branches, and the update information may be information about the update branches in the internal dependency source setting script and the external dependency source setting script. Thus, the user can update the dependent project by updating the dependency image generation script.

[0058] It should be noted that in the prior art, when it is necessary to configure or upgrade the configuration of a working node, manual operation is required, and since the working node is highly bound to the operating system type version, dependent library, environment configuration, and compilation tool chain, any change will cause the working node to be offline and unable to provide normal services. However, this embodiment relies on mirror generation scripts to automatically configure the compilation environment and dependent projects or update existing configurations before each compilation, which greatly reduces configuration costs and improves configuration efficiency. Moreover, since the compilation environment is not bound to the working node, the working node does not need to be offline during configuration or upgrade, and can provide normal services for the continuous integration of other code projects.

[0059] As one of the optional embodiments, compiling the target code project in the compilation environment of the latest compiled integrated image is specifically as follows:

[0060] The directory of the target code project and the directory of the compilation workspace are used as the compilation code source address and the compilation file output address respectively, and the latest compilation integrated image is started for compilation.

[0061] In this embodiment, after the generation and startup of the latest compiled integrated image is completed, the working node pulls the target code project to the compilation workspace, and read-only mounts the workspace directory of the target code project to the latest compiled integrated image as the compilation code source, so that the compiler in the image can access the code source file. At the same time, the compilation work is started, and the compiled file is output to the write-mounted workspace directory instead of the internal directory of the compilation image, thereby avoiding the bloat and redundancy of the container.

[0062] As one of the optional embodiments, the compiled file includes an executable file;

[0063] Before clearing the compilation workspace, the method further includes:

[0064] The executable file is saved to the release component repository.

[0065] In this embodiment, after successful compilation, the executable file is pushed to the release component warehouse for storage to facilitate subsequent testing and verification by users.

[0066] Furthermore, the dependency image generation script also includes configuration information of an image generation plug-in; the latest compiled integrated image also includes the image generation plug-in; the image generation plug-in is used to generate a compilation result image corresponding to the executable file;

[0067] The file obtained by the compilation also includes the compilation result image.

[0068] In this embodiment, since the entire compilation integration environment runs in the form of a container image, when the output result also needs to be made into a container, if the container-nested container method is used, it will cause bloat and system redundancy. If the working node container instance generation method is used, new external dependencies will be generated. To this end, this embodiment configures the configuration information of the image generation plug-in in the dependency image generation script. Therefore, when the latest compilation integration image is installed according to the dependency image generation script, the image generation plug-in can be added to the latest compilation integration image. The image generation plug-in can directly generate the compilation result image without relying on external container tools, thereby avoiding bloat and system redundancy.

[0069] For example, it can be a create_image.mk description file that is agreed upon as follows for directly generating a compilation result image, which includes the command specifying the ID of the compilation result image, base image information, identification information of the target code project, startup parameters, and packaging location. Among them, the base image information includes the name and version of the operating system that depends on the base image; the identification information of the target code project includes the code repository project ID and the code repository code version number; the packaging location refers to the packaging location of the compiled executable file. It should be noted that the image generation method of the image generation plug-in is specifically implemented by various compiler extension methods and is not limited here.

[0070] Furthermore, before clearing the compilation workspace, the method further includes:

[0071] The compilation result image is saved to the release image warehouse.

[0072] In this embodiment, after successful compilation, the compilation result image is pushed to the release image warehouse for storage to facilitate subsequent testing and verification by users.

[0073] As a specific embodiment, the method provided in this embodiment can be applied to a task integration system consisting of multiple working nodes and one master node. The method is executed by the working nodes, and the master node is the task management node. Figure 4a and 4bThe specific implementation process of the method provided in this embodiment is as follows: the developer submits the code in the code repository; when the trigger compares the code and finds that there is a change, it generates a compilation trigger request for the target code project with the change and sends it to the master node to notify the master node to assign a continuous integration task; the master node generates a continuous integration task for the target code project and sends it to any idle working node; in response to receiving the continuous integration task for the target code project sent by the master node, the working node pulls the dependent image generation script of the target code project; the working node reads the compilation integration image ID from the dependent image generation script; the working node obtains the compilation integration image corresponding to the target code project from the compilation integration image repository according to the compilation integration image ID, and if the acquisition is successful, it is updated according to the update user The information updates the compilation integrated image of the target code project to obtain the latest compilation integrated image of the target code project. If the acquisition fails, the image is installed according to the installation information to obtain the latest compilation integrated image of the target code project, and the latest compilation integrated image is associated with the image ID and saved to the compilation integrated image warehouse for use in the next compilation; the working node loads the latest compilation integrated image to the preset compilation workspace, and pulls the target code project from the code warehouse to the compilation workspace; the working node mounts the workspace directory where the target code project is located to the latest compilation integrated image in a read-only manner, starts the compilation work, and outputs the compilation result image and executable file to the write-mounted workspace directory; saves the executable file to the release component warehouse; saves the compilation result image to the release image warehouse.

[0074] See also Figure 5 , is a structural diagram of a container-based continuous integration device provided by an embodiment of the present invention.

[0075] The container-based continuous integration device provided by an embodiment of the present invention includes:

[0076] The script acquisition module 11 is configured to, in response to receiving a continuous integration task for a target code project sent by a task integration node, acquire a dependency image generation script for the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects;

[0077] An image generation module 12 is configured to generate a latest compiled integrated image of the target code project based on the dependent image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code based on the compilation environment and the dependent projects;

[0078] A code compilation module 13 is configured to allocate the latest compiled integrated image to a corresponding compilation workspace and compile the target code project in the compilation environment of the latest compiled integrated image;

[0079] The workspace clearing module 14 is used to clear the compilation workspace after the compilation is completed.

[0080] As one of the optional embodiments, the dependency image generation script further includes compiling an integrated image ID; the configuration information includes installation information and update information;

[0081] The image generation module 12 is specifically used for:

[0082] Obtaining the compiled integrated image corresponding to the target code project from the compiled integrated image repository according to the compiled integrated image ID;

[0083] If the acquisition is successful, the compiled integrated image of the target code project is updated according to the update information to obtain the latest compiled integrated image of the target code project;

[0084] If the acquisition fails, the image is installed according to the installation information to obtain the latest compiled integrated image of the target code project, and the latest compiled integrated image is associated with the compiled integrated image ID and saved in the compiled integrated image warehouse.

[0085] As one of the optional embodiments, the code compiling module 13 is specifically configured to:

[0086] The directory of the target code project and the directory of the compilation workspace are used as the compilation code source address and the compilation file output address respectively, and the latest compilation integrated image is started for compilation.

[0087] As one of the optional embodiments, the compiled file includes an executable file;

[0088] After the compilation is completed and before the compilation workspace is cleared, the apparatus further includes:

[0089] The file publishing module is used to save the executable file to the publishing component warehouse.

[0090] Furthermore, the dependency image generation script also includes configuration information of an image generation plug-in; the latest compiled integrated image also includes the image generation plug-in; the image generation plug-in is used to generate a compilation result image corresponding to the executable file;

[0091] The compiled file also includes the compilation result image.

[0092] Furthermore, the device further comprises:

[0093] The image publishing module is used to save the compilation result image to the publishing image warehouse.

[0094] See also Figure 6, is a structural diagram of a working node provided by an embodiment of the present invention.

[0095] An embodiment of the present invention provides a working node, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the container-based continuous integration method as described in any one of the above embodiments is implemented.

[0096] Figure 6 In the example, a processor 20 is used; the processor 20 and the memory 21 in the working node can be connected by a bus or other means. Figure 6 The bus connection is taken as an example.

[0097] Exemplarily, the computer program can be divided into one or more modules / units, and the one or more modules / units are stored in the memory and executed by the processor 20 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the working node. For example, the computer program can be divided into a script acquisition module, which is used to obtain the dependency image generation script of the target code project in response to receiving a continuous integration task for the target code project sent by the master node; wherein the dependency image generation script includes the configuration information of the compilation environment and dependent projects; an image generation module, which is used to generate the latest compiled integrated image of the target code project according to the dependency image generation script; wherein the latest compiled integrated image includes the compilation environment, dependent projects and a compiler for compiling code according to the compilation environment and the dependent projects; a code compilation module, which is used to assign the latest compiled integrated image to the corresponding compilation workspace, and compile the target code project in the compilation environment of the latest compiled integrated image; a workspace clearing module, which is used to clear the compilation workspace after compilation is completed. That is, the container-based continuous integration method described in the above embodiment.

[0098] The processor 20 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0099] The memory 21 can be used to store the computer programs and / or modules, such as the program instructions / modules corresponding to the container-based continuous integration method in the above embodiment of the present invention. The processor 20 implements the various functions of the work node by running or executing the computer programs and / or modules stored in the memory 21, and calling the data stored in the memory 21. The memory may mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, the memory 21 may include a high-speed random access memory, and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage device. In some instances, the memory 21 may further include a memory remotely located relative to the processor 20, and these remote memories can be connected to the work node via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0100] It should be noted that the principles and technical effects of the embodiments of the present invention are the same as those of the container-based continuous integration method described in the above embodiments, and will not be described in detail here.

[0101] See also Figure 7 , is a structural diagram of a container-based continuous integration system provided by one embodiment of the present invention.

[0102] An embodiment of the present invention provides a container-based continuous integration system, comprising a code repository 1, a trigger 2, a master node 3, and one or more worker nodes 4 as described in the above embodiment;

[0103] The code repository 1 is used to receive and store code projects submitted by users;

[0104] The trigger 2 is configured to generate a compilation trigger request for the target code project corresponding to the code change event when a code change event is detected in the code repository 1, and send the request to the master node 3;

[0105] The master node 3 is configured to respond to the compilation trigger request, generate a continuous integration task for the target code project, and send the task to any idle worker node 4.

[0106] Furthermore, the container-based continuous integration system also includes:

[0107] Compilation integrated image warehouse 5, used to store the compilation integrated image of each code project;

[0108] Release image repository 6, which is used to store the compilation result images of various code projects;

[0109] The release component repository 7 is used to store executable files of various code projects.

[0110] It should be noted that the principles and technical effects of the embodiments of the present invention are the same as those of the container-based continuous integration method described in the above embodiments, and will not be described in detail here.

[0111] Another embodiment of the present invention provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the container-based continuous integration method as described in any one of the embodiments.

[0112] The container-based continuous integration method includes:

[0113] In response to receiving a continuous integration task for a target code project sent by a master node, obtaining a dependency image generation script for the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects;

[0114] Generate the latest compiled integrated image of the target code project according to the dependent image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code according to the compilation environment and the dependent projects;

[0115] Allocating the latest compiled integrated image to a corresponding compilation workspace, and compiling the target code project in the compilation environment of the latest compiled integrated image;

[0116] After the compilation is completed, the compilation workspace is cleared.

[0117] Of course, the computer-readable storage medium provided in an embodiment of the present invention is not limited to the method operations described above, and can also perform related operations in the container-based continuous integration method provided in any embodiment of the present invention.

[0118] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0119] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A container-based continuous integration method, characterized in that: include: In response to receiving a continuous integration task for a target code project sent by a task management node, obtaining a dependency image generation script for the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects; Generate a latest compiled integrated image of the target code project according to the dependency image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code according to the compilation environment and the dependent projects; the dependency image generation script also includes a compilation integrated image ID; and the configuration information includes installation information and update information; Generating the latest compiled integrated image of the target code project according to the dependency image generation script specifically includes: Obtaining the compiled integrated image corresponding to the target code project from the compiled integrated image repository according to the compiled integrated image ID; If the acquisition is successful, the compiled integrated image of the target code project is updated according to the update information to obtain the latest compiled integrated image of the target code project; If the acquisition fails, performing image installation according to the installation information to obtain the latest compiled integrated image of the target code project, and associating the latest compiled integrated image with the compiled integrated image ID and saving it in the compiled integrated image warehouse; Allocating the latest compiled integrated image to a corresponding compilation workspace, and compiling the target code project in the compilation environment of the latest compiled integrated image; specifically, using the directory of the target code project and the directory of the compilation workspace as the compilation code source address and the compilation file output address, respectively, and starting the latest compiled integrated image for compilation; After the compilation is completed, the compilation workspace is cleared.

2. The container-based continuous integration method according to claim 1, wherein: The compiled files include executable files; After the compilation is completed and before clearing the compilation workspace, the method further includes: The executable file is saved to the release component repository.

3. The container-based continuous integration method according to claim 2, wherein: The dependency image generation script also includes configuration information of the image generation plug-in; the latest compiled integrated image also includes the image generation plug-in; the image generation plug-in is used to generate the compilation result image corresponding to the executable file; The file obtained by the compilation also includes the compilation result image.

4. The container-based continuous integration method according to claim 3, wherein: After the compilation is completed and before clearing the compilation workspace, the method further includes: The compilation result image is saved to the release image warehouse.

5. A container-based continuous integration device, characterized in that: include: a script acquisition module, configured to, in response to receiving a continuous integration task for a target code project sent by a task management node, acquire a dependency image generation script for the target code project; wherein the dependency image generation script includes configuration information of a compilation environment and dependent projects; An image generation module, configured to generate a latest compiled integrated image of the target code project based on the dependent image generation script; wherein the latest compiled integrated image includes a compilation environment, dependent projects, and a compiler for compiling code based on the compilation environment and the dependent projects; The dependency image generation script also includes compiling an integrated image ID; the configuration information includes installation information and update information; The image generation module is specifically configured to: obtain the compiled integrated image corresponding to the target code project from the compiled integrated image repository according to the compiled integrated image ID; if the acquisition is successful, update the compiled integrated image of the target code project according to the update information to obtain the latest compiled integrated image of the target code project; if the acquisition fails, perform image installation according to the installation information to obtain the latest compiled integrated image of the target code project, and associate the latest compiled integrated image with the compiled integrated image ID and save it in the compiled integrated image repository; A code compilation module is configured to allocate the latest compiled integrated image to a corresponding compilation workspace and compile the target code project in the compilation environment of the latest compiled integrated image; specifically, the module starts the latest compiled integrated image for compilation using the target code project directory and the compilation workspace directory as the compiled code source address and the compiled file output address, respectively; The workspace clearing module is used to clear the compilation workspace after the compilation is completed.

6. A working node, characterized in that: The system comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the container-based continuous integration method according to any one of claims 1 to 4 is implemented.

7. A container-based continuous integration system, characterized in that: comprising a code repository, a trigger, a master node, and one or more working nodes as claimed in claim 6; The code repository is used to receive and store code projects submitted by users; The trigger is configured to generate a compilation trigger request for a target code project corresponding to the code change event when a code change event is detected in the code repository, and send the request to the master node; The master node is configured to respond to the compilation trigger request, generate a continuous integration task for the target code project, and send the task to any idle worker node.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the container-based continuous integration method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Docker mirror image generation method and Docker container

    CN106933635A