CN118170420A - A code management method, system and computing device - Google Patents
A code management method, system and computing device Download PDFInfo
- Publication number
- CN118170420A CN118170420A CN202410139893.1A CN202410139893A CN118170420A CN 118170420 A CN118170420 A CN 118170420A CN 202410139893 A CN202410139893 A CN 202410139893A CN 118170420 A CN118170420 A CN 118170420A
- Authority
- CN
- China
- Prior art keywords
- code
- request
- target
- software package
- merge
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000007726 management method Methods 0.000 title claims abstract description 52
- 238000000034 method Methods 0.000 claims abstract description 65
- 238000010276 construction Methods 0.000 claims description 96
- 238000012552 review Methods 0.000 claims description 45
- 238000003860 storage Methods 0.000 claims description 37
- 238000004806 packaging method and process Methods 0.000 claims description 23
- 238000012546 transfer Methods 0.000 claims description 19
- 238000012795 verification Methods 0.000 claims description 11
- 238000012856 packing Methods 0.000 claims 3
- 239000000758 substrate Substances 0.000 claims 1
- 238000012545 processing Methods 0.000 abstract description 26
- 230000004044 response Effects 0.000 abstract description 10
- 238000011161 development Methods 0.000 abstract description 8
- 230000008569 process Effects 0.000 description 32
- 230000006870 function Effects 0.000 description 15
- 238000012360 testing method Methods 0.000 description 14
- 238000010586 diagram Methods 0.000 description 7
- 239000003999 initiator Substances 0.000 description 7
- 238000004590 computer program Methods 0.000 description 6
- 239000000203 mixture Substances 0.000 description 6
- 238000012986 modification Methods 0.000 description 6
- 230000004048 modification Effects 0.000 description 6
- 238000004519 manufacturing process Methods 0.000 description 5
- 238000011084 recovery Methods 0.000 description 4
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 3
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 3
- 230000001419 dependent effect Effects 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 238000013515 script Methods 0.000 description 3
- 239000002699 waste material Substances 0.000 description 3
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 2
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 2
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 230000010354 integration Effects 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000012858 packaging process Methods 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001502 supplementing effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
Description
技术领域Technical Field
本申请实施例涉及计算设备技术领域,尤其涉及一种代码管理方法、系统及计算设备。The embodiments of the present application relate to the technical field of computing devices, and in particular, to a code management method, system and computing device.
背景技术Background technique
在软件开发的过程中,一般采用Codehub系统与Jenkins系统组合构建门禁工程,用于对实现对新增代码的评审以及自动编译验证。通常,由Codehub系统对新增代码进行评审。评审通过后,由Jenkins系统对评审通过后的新增代码进行编译和验证。在验证无问题后,Jenkins系统还可以将新增代码部署到测试环境或者生产环境,以进行进一步的测试或上线运行。可以看出,门禁工程对新增代码的处理过程是影响软件开发进度的重要因素。如何针对该过程,提高门禁工程的效率,成为亟待解决的技术问题。In the process of software development, the Codehub system and the Jenkins system are generally used to build an access control project, which is used to review and automatically compile and verify the newly added code. Usually, the Codehub system reviews the newly added code. After the review is passed, the Jenkins system compiles and verifies the newly added code that has passed the review. After verification, the Jenkins system can also deploy the newly added code to the test environment or production environment for further testing or online operation. It can be seen that the processing process of the access control project for the newly added code is an important factor affecting the progress of software development. How to improve the efficiency of the access control project in view of this process has become a technical problem that needs to be solved urgently.
发明内容Summary of the invention
本申请实施例提供一种代码管理方法、系统及计算设备,可以提高门禁工程的效率,保证项目开发的进度。The embodiments of the present application provide a code management method, system and computing device, which can improve the efficiency of access control projects and ensure the progress of project development.
第一方面,本申请实施例提供一种代码管理方法,该方法包括:接收合并请求;所述合并请求用于请求合并目标代码与源代码并且指示是否生成软件包;所述软件包包括所述目标代码与所述源代码,以及支持所述目标代码和所述源代码运行的运行环境;响应于所述合并请求,合并所述目标代码与所述源代码得到第一代码;编译所述第一代码;在所述第一代码编译验证成功后,基于所述目标代码更新所述源代码得到第二代码;在所述合并请求指示生成软件包的情况下,将所述第二代码打包,生成软件包。In a first aspect, an embodiment of the present application provides a code management method, the method comprising: receiving a merge request; the merge request is used to request a merge of a target code and a source code and indicate whether to generate a software package; the software package includes the target code and the source code, and an operating environment that supports the operation of the target code and the source code; in response to the merge request, merging the target code and the source code to obtain a first code; compiling the first code; after the compilation and verification of the first code is successful, updating the source code based on the target code to obtain a second code; and when the merge request indicates the generation of a software package, packaging the second code to generate a software package.
本申请实施例提供一种代码管理方法。该方法中项目构建平台可以接收并响应于代码评审平台的合并请求,执行代码的合并以及编译验证后,可以在合并请求指示生成软件包的情况下,进一步基于更新得到的第二代码打包,以生成软件包。可以看出,本申请实施例提供的方法可以基于合并请求的指示,按需执行对第二代码打包生成软件包的步骤。这样可以避免项目构建平台无差别的对每次合并请求生成的代码打包,浪费计算资源的同时增加了处理流程,影响项目构建平台的处理效率。另外,在开发人员存在生成软件包的需求时,无需开发人员手动通过命令配置以使得项目构建平台执行打包的过程,降低开发人员使用项目构建平台的技术门槛。The embodiment of the present application provides a code management method. In the method, the project construction platform can receive and respond to the merge request of the code review platform, execute the merge of the code and compile verification, and can further package the second code obtained based on the update to generate the software package when the merge request indicates the generation of the software package. It can be seen that the method provided by the embodiment of the present application can perform the step of packaging the second code to generate the software package on demand based on the indication of the merge request. In this way, it is possible to avoid the project construction platform from packaging the code generated by each merge request indiscriminately, which wastes computing resources while increasing the processing flow and affecting the processing efficiency of the project construction platform. In addition, when the developer has the need to generate a software package, there is no need for the developer to manually configure the command so that the project construction platform executes the packaging process, thereby reducing the technical threshold for developers to use the project construction platform.
在一种可能的实现方式中,在合并请求包括第一字段的情况下,或者在合并请求未包括第二字段的情况下,合并请求用于指示生成软件包;其中,第一字段为用于指示生成软件包的字段,第二字段为用于指示不生成软件包的字段。In a possible implementation, when the merge request includes the first field, or when the merge request does not include the second field, the merge request is used to indicate generation of a software package; wherein the first field is a field used to indicate generation of a software package, and the second field is a field used to indicate not generation of a software package.
在另一种可能的实现方式中,基于第二代码生成软件包,包括:获取配置文件;配置文件为用于支持源代码运行的文件;从配置文件中确定目标配置文件;目标配置文件用于指示基于代码生成软件包的方式;根据目标配置文件的文件名确定软件包的包名;基于包名将第二代码打包,生成软件包。In another possible implementation, generating a software package based on the second code includes: obtaining a configuration file; the configuration file is a file used to support the running of the source code; determining a target configuration file from the configuration file; the target configuration file is used to indicate a method for generating the software package based on the code; determining a package name of the software package according to a file name of the target configuration file; and packaging the second code based on the package name to generate the software package.
在又一种可能的实现方式中,合并请求包括:目标代码的仓库地址和合并补丁的信息;合并补丁用于将目标代码与源代码合并以得到第一代码;合并目标代码与源代码得到第一代码,包括:根据目标代码的仓库地址,下载目标代码至本地代码仓库;本地代码仓库为项目构建平台中用于存储代码的存储空间,本地代码仓库中还包括源代码;根据合并补丁的信息,获取合并补丁;将合并补丁配置到本地代码仓库中,以完成目标代码与源代码的合并,得到第一代码。In another possible implementation, the merge request includes: the repository address of the target code and information of the merge patch; the merge patch is used to merge the target code with the source code to obtain the first code; merging the target code with the source code to obtain the first code includes: downloading the target code to the local code repository according to the repository address of the target code; the local code repository is a storage space for storing code in the project build platform, and the local code repository also includes source code; obtaining the merge patch according to the information of the merge patch; configuring the merge patch to the local code repository to complete the merge of the target code and the source code to obtain the first code.
在又一种可能的实现方式中,合并请求还包括:配置文件的仓库地址;编译第一代码,包括:根据配置文件的仓库地址,下载配置文件至本地配方仓库;本地配方仓库为项目构建平台中用于存储配置文件的存储空间;根据目标代码的仓库地址,从本地配方仓库中确定对应的目标配置文件;修改目标配置文件中用于索引代码的地址为本地代码仓库的地址;在本地配方仓库中对第一代码进行编译。In another possible implementation, the merge request also includes: the repository address of the configuration file; compiling the first code, including: downloading the configuration file to the local recipe repository according to the repository address of the configuration file; the local recipe repository is a storage space for storing configuration files in the project build platform; determining the corresponding target configuration file from the local recipe repository according to the repository address of the target code; modifying the address for indexing the code in the target configuration file to the address of the local code repository; and compiling the first code in the local recipe repository.
在又一种可能的实现方式中,项目构建平台通过中转平台与代码评审平台连接;接收合并请求,包括:接收中转平台第二合并请求;第二合并请求为中转平台对代码评审平台发送的第一合并请求处理后的请求;其中,第一合并请求是符合超文本传输协议规定格式的请求,第二合并请求是符合项目构建平台规定格式的请求。In another possible implementation, the project construction platform is connected to the code review platform through a transit platform; receiving a merge request includes: receiving a second merge request from the transit platform; the second merge request is a request after the transit platform processes the first merge request sent by the code review platform; wherein the first merge request is a request in a format that complies with a hypertext transfer protocol, and the second merge request is a request in a format that complies with a format that complies with a project construction platform.
第二方面,本申请实施例提供一种代码管理系统,包括代码评审平台以及项目构建平台;代码评审平台与项目构建平台连接;代码评审平台用于,生成合并请求,并将合并请求发送至项目构建平台;合并请求用于请求合并目标代码与源代码并且指示是否生成软件包;软件包包括目标代码与源代码,以及支持目标代码和源代码运行的运行环境;项目构建平台用于,响应于合并请求,合并目标代码与源代码得到第一代码;编译第一代码;在第一代码编译验证成功后,基于目标代码更新源代码得到第二代码;在合并请求指示生成软件包的情况下,将第二代码打包,生成软件包。In a second aspect, an embodiment of the present application provides a code management system, including a code review platform and a project construction platform; the code review platform is connected to the project construction platform; the code review platform is used to generate a merge request and send the merge request to the project construction platform; the merge request is used to request a merge of a target code and a source code and indicate whether to generate a software package; the software package includes the target code and the source code, and an operating environment that supports the operation of the target code and the source code; the project construction platform is used to, in response to the merge request, merge the target code and the source code to obtain a first code; compile the first code; after the compilation and verification of the first code is successful, update the source code based on the target code to obtain a second code; when the merge request indicates the generation of a software package, package the second code to generate a software package.
在一种可能的实现方式中,在合并请求包括第一字段的情况下,或者在合并请求未包括第二字段的情况下,合并请求用于指示生成软件包;其中,第一字段为用于指示生成软件包的字段,第二字段为用于指示不生成软件包的字段。In a possible implementation, when the merge request includes the first field, or when the merge request does not include the second field, the merge request is used to indicate generation of a software package; wherein the first field is a field used to indicate generation of a software package, and the second field is a field used to indicate not generation of a software package.
在另一种可能的实现方式中,项目构建平台具体用于,获取配置文件,从配置文件中确定目标配置文件;根据目标配置文件的文件名确定软件包的包名;基于包名将第二代码打包,生成软件包;其中,配置文件为用于支持源代码运行的文件,目标配置文件用于指示基于代码生成软件包的方式。In another possible implementation, the project construction platform is specifically used to obtain a configuration file, determine a target configuration file from the configuration file; determine a package name of a software package according to the file name of the target configuration file; package the second code based on the package name to generate a software package; wherein the configuration file is a file used to support the running of source code, and the target configuration file is used to indicate a method of generating a software package based on the code.
在又一种可能的实现方式中,合并请求包括:目标代码的仓库地址和合并补丁的信息;合并补丁用于将目标代码与源代码合并以得到第一代码;项目构建平台具体用于,响应于合并请求,根据目标代码的仓库地址,下载目标代码至本地代码仓库;本地代码仓库为项目构建平台中用于存储代码的存储空间,本地代码仓库中还包括源代码;根据合并补丁的信息,获取合并补丁;将合并补丁配置到本地代码仓库中,以完成目标代码与源代码的合并,得到第一代码。In another possible implementation, the merge request includes: the repository address of the target code and information of the merge patch; the merge patch is used to merge the target code with the source code to obtain the first code; the project construction platform is specifically used to, in response to the merge request, download the target code to the local code repository according to the repository address of the target code; the local code repository is a storage space for storing code in the project construction platform, and the local code repository also includes source code; according to the information of the merge patch, obtain the merge patch; configure the merge patch to the local code repository to complete the merge of the target code and the source code to obtain the first code.
在又一种可能的实现方式中,合并请求还包括:配置文件的仓库地址;项目构建平台具体用于,根据配置文件的仓库地址,下载配置文件至本地配方仓库;本地配方仓库为项目构建平台中用于存储配置文件的存储空间;根据目标代码的仓库地址,从本地配方仓库中确定对应的目标配置文件;修改目标配置文件中用于索引代码的地址修改为本地代码仓库的地址;在本地配方仓库中对第一代码进行编译。In another possible implementation, the merge request also includes: the repository address of the configuration file; the project build platform is specifically used to download the configuration file to the local recipe repository according to the repository address of the configuration file; the local recipe repository is a storage space in the project build platform for storing configuration files; according to the repository address of the target code, determining the corresponding target configuration file from the local recipe repository; modifying the address for indexing the code in the target configuration file to the address of the local code repository; and compiling the first code in the local recipe repository.
在又一种可能的实现方式中,代码管理系统还包括:中转平台;中转平台用于连接代码评审平台以及项目构建平台;中转平台用于,接收代码评审平台发送的第一合并请求,并根据第一合并请求生成第二合并请求,发送第二合并请求至项目构建平台;其中,第一合并请求是符合超文本传输协议规定格式的请求,第二合并请求是符合项目构建平台规定格式的请求。In another possible implementation, the code management system also includes: a transfer platform; the transfer platform is used to connect the code review platform and the project construction platform; the transfer platform is used to receive a first merge request sent by the code review platform, and generate a second merge request based on the first merge request, and send the second merge request to the project construction platform; wherein the first merge request is a request that complies with the format specified by the Hypertext Transfer Protocol, and the second merge request is a request that complies with the format specified by the project construction platform.
第三方面,本申请实施例提供一种计算设备,该计算设备包括处理器和存储器;处理器与存储器耦合;存储器用于存储计算机指令,计算机指令由处理器加载并执行以使计算设备实现上述第一方面的方法。In a third aspect, an embodiment of the present application provides a computing device, which includes a processor and a memory; the processor is coupled to the memory; the memory is used to store computer instructions, and the computer instructions are loaded and executed by the processor to enable the computing device to implement the method of the first aspect above.
第四方面,本申请实施例提供一种计算机可读存储介质,该计算机可读存储介质包括:计算机软件指令;当计算机软件指令在计算设备中运行时,使得计算设备实现上述第一方面的方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes: computer software instructions; when the computer software instructions are executed in a computing device, the computing device implements the method of the first aspect above.
第五方面,本申请实施例提供一种计算机程序产品,当该计算机程序产品在计算设备上运行时,使得计算设备执行上述第二方面描述的相关方法的步骤,以实现上述第一方面的方法。In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a computing device, the computing device executes the steps of the related method described in the second aspect to implement the method of the first aspect.
上述第二方面至第五方面的有益效果可以参考第一方面的对应描述,不再赘述。The beneficial effects of the second to fifth aspects mentioned above can be referred to the corresponding description of the first aspect and will not be repeated here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为本申请实施例提供的一种代码管理系统的组成示意图;FIG1 is a schematic diagram of the composition of a code management system provided in an embodiment of the present application;
图2为本申请实施例提供的另一种代码管理系统的组成示意图;FIG2 is a schematic diagram of another code management system provided in an embodiment of the present application;
图3为本申请实施例提供的一种代码管理方法的流程示意图;FIG3 is a flow chart of a code management method provided in an embodiment of the present application;
图4为本申请实施例提供的另一种代码管理方法的流程示意图;FIG4 is a flow chart of another code management method provided in an embodiment of the present application;
图5为本申请实施例提供的又一种代码管理方法的流程示意图;FIG5 is a flow chart of another code management method provided in an embodiment of the present application;
图6为本申请实施例提供的一种合并事件执行流程图;FIG6 is a flowchart of a merge event execution provided by an embodiment of the present application;
图7为本申请实施例提供的一种代码管理装置的组成示意图;FIG7 is a schematic diagram of the composition of a code management device provided in an embodiment of the present application;
图8为本申请实施例提供的一种计算设备的组成示意图。FIG8 is a schematic diagram of the composition of a computing device provided in an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
需要说明的是,本申请实施例中,“示例性地”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性地”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性地”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that, in the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分,本领域技术人员可以理解“第一”、“第二”等字样并不是在对数量和执行次序进行限定。In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical items or similar items with basically the same functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order.
下面对本申请实施例涉及到的技术术语进行解释说明。The technical terms involved in the embodiments of the present application are explained below.
1、开放基板管理控制器(open baseboard manager controller,OpenBMC),是BMC的Linux发行版,旨在跨越异构系统,包括企业、高性能计算(high performancecomputing,HPC)、电信和云规模数据中心等对服务器进行管理。OpenBMC提供了一个开放的、可定制的BMC固件解决方案,以便服务器制造商和开发人员能够自定义和扩展BMC的功能。1. Open baseboard manager controller (OpenBMC) is a Linux distribution of BMC, designed to manage servers across heterogeneous systems, including enterprise, high performance computing (HPC), telecommunications and cloud-scale data centers. OpenBMC provides an open and customizable BMC firmware solution so that server manufacturers and developers can customize and extend the functionality of the BMC.
2、Yocto:是一个开源的协作软件,提供模板、工具和方法以创建定制的Linux系统和嵌入式产品,而无需关心硬件体系。2. Yocto: is an open source collaborative software that provides templates, tools and methods to create customized Linux systems and embedded products without worrying about the hardware system.
3、Jenkins:是一款开源的持续集成工具,用于自动化各种任务,包括软件项目的构建、测试和部署等流程化管理。其中,持续集成具有如下特点:自动化及周期性的集成测试过程,从获取代码、编译构建、运行测试、结果记录、测试统计等都是自动完成的,无需人工干预。3. Jenkins: It is an open source continuous integration tool used to automate various tasks, including process management such as software project construction, testing and deployment. Among them, continuous integration has the following characteristics: automated and periodic integrated testing process, from obtaining code, compiling and building, running tests, result recording, test statistics, etc. are all completed automatically without manual intervention.
4、Codehub:是一个基于网页(web)的代码评审工具,Codehub可以将一个开发人员提交的代码分发给其他开发人员,实现对代码的多人评审,在评审通过后Codehub可以将代码做进一步处理,例如发送给Jenkins进行部署等。它基于分布式版本控制系统(git)实现代码的管理。git的特点是可以支持不同的开发人员在各自的用户侧设备上,对共同开发的项目的源代码进行操作,以修复源代码的故障或者增加新的功能等。4. Codehub: It is a web-based code review tool. Codehub can distribute the code submitted by a developer to other developers to realize multi-person code review. After the review is passed, Codehub can further process the code, such as sending it to Jenkins for deployment. It implements code management based on the distributed version control system (git). The feature of git is that it can support different developers to operate the source code of the jointly developed project on their respective user-side devices to fix source code failures or add new functions.
5、bitbake:是一个任务执行引擎,类似于一个脚本解释器。主要用于在基于Yocto开发的项目中解析并执行构建脚本,构建软件包和生成镜像等。5. bitbake: It is a task execution engine, similar to a script interpreter. It is mainly used to parse and execute build scripts, build software packages, and generate images in Yocto-based projects.
6、gerrit:是一个基于网页的代码评审工具,与Codehub的功能相似,可以支持多个开发人员协同开发项目。6. Gerrit: It is a web-based code review tool with similar functions to Codehub, which can support multiple developers to collaborate on projects.
7、分支和主分支:由git中引入的概念,Jenkins中也是基于分支进行代码管理。代码的分支可以理解为是代码的不同版本,例如某个代码可以有两个分支,一个分支用于开发人员进行测试,一个分支用于代码的正式上线运行。以源代码为例,若源代码仅有一个版本,则默认称为源代码的主分支。开发人员在进行开发时,可以基于源代码的主分支复制源代码到用户侧设备上,以基于源代码进行开发。为便于描述,下文中统一称呼新增代码为目标代码(类似的,开发人员在编写目标代码时,也可能基于目标代码创建多个分支),目标代码与源代码合并后的代码称为第一代码,基于目标代码对源代码更新后得到的代码称为第二代码。第一代码和第二代码的区别在于,第一代码是将目标代码和源代码临时合并以进行编译验证,第二代码是确定目标代码无问题后,将目标代码存储到源代码对应的文件或代码库中得到的更新后的代码,可以便于后续的部署上线。7. Branches and main branches: The concept introduced by git is also based on branches for code management in Jenkins. Code branches can be understood as different versions of the code. For example, a code can have two branches, one for developers to test and the other for the official online operation of the code. Taking the source code as an example, if the source code has only one version, it is called the main branch of the source code by default. When the developer is developing, he can copy the source code to the user-side device based on the main branch of the source code to develop based on the source code. For the convenience of description, the new code is uniformly called the target code below (similarly, when the developer writes the target code, he may also create multiple branches based on the target code). The code after the target code and the source code are merged is called the first code, and the code obtained after the source code is updated based on the target code is called the second code. The difference between the first code and the second code is that the first code is to temporarily merge the target code and the source code for compilation verification, and the second code is to store the target code in the file or code library corresponding to the source code after determining that there is no problem with the target code, which is the updated code obtained, which can facilitate subsequent deployment and online.
8、代码仓库:指的是用于存储代码(如源代码和目标代码)的存储空间。本申请实施例中提及的本地代码仓库指的是项目构建平台创建的用于存储代码的存储空间。8. Code repository: refers to a storage space used to store code (such as source code and object code). The local code repository mentioned in the embodiments of the present application refers to a storage space created by the project construction platform for storing code.
9、配方仓库:指的是用于存储支持代码运行的相关配置文件的存储空间。本申请实施例中提及的本地配方仓库指的是项目构建平台创建的用于存储源代码对应的配置文件的存储空间。9. Recipe warehouse: refers to the storage space used to store relevant configuration files that support code execution. The local recipe warehouse mentioned in the embodiments of the present application refers to the storage space created by the project construction platform to store configuration files corresponding to the source code.
如背景技术的描述,在软件开发的过程中,一般采用Codehub系统与Jenkins系统组合构建门禁工程。门禁工程指的是对目标代码进行编译和验证,在确保目标代码运行无问题的情况下才可以将目标代码合并到源代码的主分支上或发布到测试环境/生产环境,以减少错误和故障的发生。其中,测试环境用于代码在上线(即发布到生成环境)前的进一步测试,测试环境与生产环境基本类似,可以保证上线后代码运行无问题。在Codehub系统与Jenkins系统组合构建的门禁工程中,开发人员可以通过Codehub系统向Jenkins系统提交评审后的目标代码,例如Codehub系统可以通过合并请求(merge request,MR),触发Jenkins系统执行自动构建任务,Jenkins系统响应于该合并请求,可以执行自动构建任务,包括获取开发人员提交的目标代码,与源代码合并后进行编译和验证。该编译和验证的过程中,可以暂时建立目标代码与源代码的关系,使得目标代码可以临时运行以进行验证。若编译结果指示编译成功,则允许目标代码进行代码入库。若编译结果指示编译失败,则Jenkins系统可以阻止此次新增的目标代码入库,并通知开发人员需要修复的问题。其中,代码入库即指的是前述基于目标代码对源代码进行更新的过程,可以理解是将目标代码写入到源代码对应的文件中(或者说将目标代码存储到源代码对应的代码库中),便于后续的代码的上线部署。As described in the background technology, in the process of software development, the Codehub system and the Jenkins system are generally used to build the access control project. The access control project refers to compiling and verifying the target code. Only when the target code is guaranteed to run without problems can the target code be merged into the main branch of the source code or released to the test environment/production environment to reduce the occurrence of errors and failures. Among them, the test environment is used for further testing of the code before it goes online (i.e., it is released to the production environment). The test environment is basically similar to the production environment, which can ensure that the code runs without problems after going online. In the access control project built by the Codehub system and the Jenkins system, developers can submit the reviewed target code to the Jenkins system through the Codehub system. For example, the Codehub system can trigger the Jenkins system to perform automatic build tasks through a merge request (merge request, MR). The Jenkins system responds to the merge request and can perform automatic build tasks, including obtaining the target code submitted by the developer, merging it with the source code, and then compiling and verifying it. During the compilation and verification process, the relationship between the target code and the source code can be temporarily established so that the target code can be temporarily run for verification. If the compilation result indicates that the compilation is successful, the target code is allowed to be stored in the code library. If the compilation result indicates that the compilation has failed, the Jenkins system can prevent the newly added target code from being stored in the repository and notify the developer of the problems that need to be fixed. Code storage refers to the process of updating the source code based on the target code, which can be understood as writing the target code into the file corresponding to the source code (or storing the target code in the code library corresponding to the source code) to facilitate the subsequent online deployment of the code.
应理解,在软件开发过程中,代码(例如前述源代码和第一代码)只能在特定的计算设备中执行,例如代码运行需要计算设备上配置有运行环境(例如安装有编译器,以及支持代码运行的依赖包等)。针对其他设备(例如一般用户的用户侧设备)来说,由于缺少运行环境,是无法通过直接执行代码来实现软件运行的。针对这种情况,需要通过对代码打包成软件包(也称安装包或者应用程序(application,APP)包)并归档(存储),这样可以将代码以软件包的形式发送至其他设备上,以通过在其他设备上运行软件包来实现对代码功能的进一步测试,或者供用户正常下载使用。It should be understood that in the software development process, the code (such as the aforementioned source code and the first code) can only be executed in a specific computing device. For example, the code operation requires the computing device to be configured with an operating environment (such as a compiler installed, and dependent packages that support code operation, etc.). For other devices (such as user-side devices of general users), due to the lack of an operating environment, it is impossible to implement software operation by directly executing the code. In response to this situation, it is necessary to package the code into a software package (also called an installation package or an application (APP) package) and archive (store), so that the code can be sent to other devices in the form of a software package, so as to implement further testing of the code function by running the software package on other devices, or for users to download and use normally.
目前的门禁工程,在处理合并请求时,针对是否将更新后的第二代码打包成软件包的情况,没有合理的处理方式。若针对每次合并请求均执行打包的步骤,则增加了处理流程,影响门禁工程的处理效率,进一步影响项目的开发进度。The current access control project has no reasonable way to handle whether to package the updated second code into a software package when processing merge requests. If the packaging step is performed for each merge request, the processing flow will be increased, affecting the processing efficiency of the access control project and further affecting the development progress of the project.
另外,若门禁工程针对合并请求默认不执行打包的步骤,在开发人员存在生成软件包的需求的情况下,则需要开发人员手动在门禁工程上通过命令进行配置,以创建打包任务,使得门禁工程可以执行打包动作,这样对开发人员的技术水平要求较高,且也会影响门禁工程的处理效率。In addition, if the access control project does not perform the packaging step for merge requests by default, when the developer has the need to generate a software package, the developer is required to manually configure the access control project through commands to create a packaging task so that the access control project can perform the packaging action. This requires a high level of technical skills from the developer and will also affect the processing efficiency of the access control project.
举个例子来说,以新功能开发的场景,开发人员需要代码合并时生成软件包,以将软件包上线供用户下载使用,使得用户可以体验到新功能,即这种情况下开发人员存在生成软件包的需求。For example, in the scenario of developing a new function, developers need to generate a software package when merging codes, so that the software package can be put online for users to download and use, so that users can experience the new function. In this case, developers need to generate a software package.
在代码维护的场景中,可能存在多个开发人员分别对源代码的不同部分进行维护。这种情况下,若某个开发人员提交了合并请求,对自身负责的部分进行了维护。此时对源代码进行打包生成软件包的意义不大(因为需要在所有开发人员均提交合并请求后再进行打包,保证软件包中所有部分都得到了维护)。即这种情况下开发人员不存在生成软件包的需求。In the code maintenance scenario, there may be multiple developers who maintain different parts of the source code. In this case, if a developer submits a merge request and maintains the part he is responsible for, it is not very meaningful to package the source code to generate a software package (because it is necessary to package after all developers submit merge requests to ensure that all parts of the software package are maintained). In other words, in this case, the developer does not need to generate a software package.
基于此,本申请实施例提供一种代码管理方法。该方法中项目构建平台可以接收并响应于代码评审平台的合并请求,执行代码的合并以及编译验证后,可以在合并请求指示生成软件包的情况下,进一步基对更新得到的第二代码打包,以生成软件包。可以看出,本申请实施例提供的方法中,项目构建平台可以基于合并请求的指示,按需执行对第二代码打包生成软件包的步骤。这样可以避免项目构建平台无差别的对每次合并请求生成的代码打包,浪费计算资源的同时增加了处理流程,影响项目构建平台的处理效率。另外,在开发人员存在生成软件包的需求时,无需开发人员手动通过命令配置以使得项目构建平台执行打包的过程,降低对开发人员使用项目构建平台的技术门槛。Based on this, the embodiment of the present application provides a code management method. In the method, the project construction platform can receive and respond to the merge request of the code review platform, execute the merge of the code and compile verification, and can further package the second code obtained by the update based on the merge request instruction to generate a software package to generate a software package. It can be seen that in the method provided by the embodiment of the present application, the project construction platform can perform the step of packaging the second code to generate a software package on demand based on the instruction of the merge request. In this way, it is possible to avoid the project construction platform from packaging the code generated by each merge request indiscriminately, wasting computing resources while increasing the processing flow, affecting the processing efficiency of the project construction platform. In addition, when the developer has the need to generate a software package, there is no need for the developer to manually configure the command so that the project construction platform executes the process of packaging, thereby reducing the technical threshold for developers to use the project construction platform.
图1为本申请实施例提供的一种代码管理系统的组成示意图,如图1所示,代码管理系统100,包括代码评审平台101以及项目构建平台102。FIG1 is a schematic diagram of the composition of a code management system provided in an embodiment of the present application. As shown in FIG1 , a code management system 100 includes a code review platform 101 and a project construction platform 102 .
代码评审平台101用于,生成合并请求,并将合并请求发送至项目构建平台102;合并请求用于请求合并目标代码与源代码并且指示是否生成软件包;软件包包括目标代码与源代码,以及支持所述目标代码和源代码运行的运行环境;The code review platform 101 is used to generate a merge request and send the merge request to the project construction platform 102; the merge request is used to request to merge the target code and the source code and indicate whether to generate a software package; the software package includes the target code and the source code, and an operating environment that supports the operation of the target code and the source code;
项目构建平台102用于,响应于合并请求,合并目标代码与源代码得到第一代码;编译第一代码;在第一代码编译验证成功后,基于目标代码更新源代码得到第二代码;在合并请求指示生成软件包的情况下,将第二代码打包,生成软件包。The project construction platform 102 is used to, in response to a merge request, merge the target code and the source code to obtain a first code; compile the first code; after the first code compilation is successfully verified, update the source code based on the target code to obtain a second code; and when the merge request indicates to generate a software package, package the second code to generate a software package.
在一些实施方式中,在合并请求包括第一字段的情况下,或者在合并请求未包括第二字段的情况下,合并请求用于指示生成软件包;其中,第一字段为用于指示生成软件包的字段,第二字段为用于指示不生成软件包的字段。In some implementations, when the merge request includes a first field, or when the merge request does not include a second field, the merge request is used to indicate generation of a software package; wherein the first field is a field used to indicate generation of a software package, and the second field is a field used to indicate not generation of a software package.
在一些实施方式中,项目构建平台102具体用于,获取配置文件,从配置文件中确定目标代码目标配置文件;根据目标配置文件的文件名确定软件包的包名;基于包名将第二代码打包,生成软件包;其中,配置文件为用于支持源代码运行的文件,目标配置文件用于指示基于代码生成软件包的方式。In some embodiments, the project construction platform 102 is specifically used to obtain a configuration file, determine a target code target configuration file from the configuration file; determine a package name of a software package according to the file name of the target configuration file; package the second code based on the package name to generate a software package; wherein the configuration file is a file used to support source code operation, and the target configuration file is used to indicate a method for generating a software package based on the code.
在一些实施方式中,合并请求包括:目标代码的仓库地址和合并补丁的信息;合并补丁用于将目标代码与源代码合并以得到第一代码;项目构建平台102具体用于,响应于合并请求,根据目标代码的仓库地址,下载目标代码至本地代码仓库;本地代码仓库为项目构建平台中用于存储代码的存储空间,本地代码仓库中还包括源代码;根据合并补丁的信息,获取合并补丁;将合并补丁配置到本地代码仓库中,以完成目标代码与源代码的合并,得到第一代码。In some embodiments, the merge request includes: the repository address of the target code and the information of the merge patch; the merge patch is used to merge the target code with the source code to obtain the first code; the project construction platform 102 is specifically used to, in response to the merge request, download the target code to the local code repository according to the repository address of the target code; the local code repository is a storage space for storing code in the project construction platform, and the local code repository also includes source code; according to the information of the merge patch, obtain the merge patch; configure the merge patch to the local code repository to complete the merge of the target code and the source code to obtain the first code.
在一些实施方式中,合并请求还包括:配置文件的仓库地址;项目构建平台102具体用于,根据配置文件的仓库地址,下载配置文件至本地配方仓库;本地配方仓库为项目构建平台中用于存储配置文件的存储空间;根据目标代码的仓库地址,从本地配方仓库中确定对应的目标配置文件;修改目标配置文件用于索引代码的地址为本地代码仓库的地址;在本地配方仓库中对第一代码进行编译。其中,本地代码仓库与本地配方仓库可以理解是同一个计算设备中的不同目录。应理解,通过修改地址,使得目标配置文件可以访问到本地代码仓库中的代码,以进行后续的代码编译流程。In some embodiments, the merge request also includes: the warehouse address of the configuration file; the project construction platform 102 is specifically used to download the configuration file to the local recipe warehouse according to the warehouse address of the configuration file; the local recipe warehouse is a storage space in the project construction platform for storing configuration files; according to the warehouse address of the target code, the corresponding target configuration file is determined from the local recipe warehouse; the address of the target configuration file used to index the code is modified to the address of the local code warehouse; the first code is compiled in the local recipe warehouse. Among them, the local code warehouse and the local recipe warehouse can be understood as different directories in the same computing device. It should be understood that by modifying the address, the target configuration file can access the code in the local code warehouse to perform subsequent code compilation processes.
在一些实施方式中,如图2所示,代码管理系统100还包括:中转平台103;中转平台103用于连接代码评审平台101以及项目构建平台102;中转平台103用于,接收代码评审平台发送的第一合并请求,并根据第一合并请求生成第二合并请求,发送第二合并请求至项目构建平台;其中,第一合并请求是符合超文本传输协议(hypertext transfer protocol,HTTP)规定格式的请求,第二合并请求是符合项目构建平台规定格式的请求。In some embodiments, as shown in FIG. 2 , the code management system 100 further includes: a transfer platform 103; the transfer platform 103 is used to connect the code review platform 101 and the project construction platform 102; the transfer platform 103 is used to receive a first merge request sent by the code review platform, generate a second merge request based on the first merge request, and send the second merge request to the project construction platform; wherein the first merge request is a request in a format that complies with the hypertext transfer protocol (HTTP), and the second merge request is a request in a format that complies with the project construction platform.
为便于描述,下文中称代码评审平台101向中转平台103发送的合并请求称为第一合并请求。中转平台103向项目构建平台101发送的合并请求称为第二合并请求。第一合并请求和第二合并请求都可以是POST请求,其特点是在请求的请求体中携带本次合并时所需要的相关参数(如目标仓库地址等)以保证安全。第一合并请求和第二合并请求的区别在于,第一合并请求是符合超文本传输协议规定格式的请求,而第二合并请求是符合Jenkins系统规定格式的请求。For ease of description, the merge request sent by the code review platform 101 to the transit platform 103 is referred to as the first merge request below. The merge request sent by the transit platform 103 to the project construction platform 101 is referred to as the second merge request. Both the first merge request and the second merge request can be POST requests, which are characterized by carrying the relevant parameters required for this merge (such as the target warehouse address, etc.) in the request body to ensure security. The difference between the first merge request and the second merge request is that the first merge request is a request that complies with the format specified by the Hypertext Transfer Protocol, while the second merge request is a request that complies with the format specified by the Jenkins system.
示例性的,以基于Yocto开发OpenBMC项目为例,基于Jenkins系统和Codehub系统搭建门禁工程(即本申请技术方案的代码管理系统),该门禁工程可以对OpenBMC项目的相关代码进行管理与部署。For example, taking the development of the OpenBMC project based on Yocto as an example, a access control project (i.e., the code management system of the technical solution of this application) is built based on the Jenkins system and the Codehub system. The access control project can manage and deploy the relevant codes of the OpenBMC project.
首先,搭建Jenkins系统用于部署OpenBMC项目,作为一种示例,该Jenkins系统的统一资源定位(uniform resource locator,URL)地址可以为“http://Jenkins.com”。进一步的,创建一个Jenkins任务作为门禁工程,例如,该门禁工程命名可以为MR_OpenBMC_APP,对应的URL地址为:http://[Jenkins地址]job/[门禁工程名]/buildWithParameters。First, build a Jenkins system to deploy the OpenBMC project. As an example, the uniform resource locator (URL) address of the Jenkins system can be "http://Jenkins.com". Further, create a Jenkins task as a door access control project. For example, the door access control project can be named MR_OpenBMC_APP, and the corresponding URL address is: http://[Jenkins address]job/[door access control project name]/buildWithParameters.
可选的,由于Codehub系统与Jenkins系统之间的差异性,两者的通信协议上存在一定的区别(例如携带请求参数的格式上存在一定区别)。因此为了方便Jenkins系统可以接收并执行Codehub系统发送的合并请求,可以搭建中转Web服务,用于接收Codehub的合并请求,并触发Jenkin系统执行合并任务。例如,该中转Web服务的URL地址为“http://zhongzhuan.com”。Optionally, due to the differences between the Codehub system and the Jenkins system, there are certain differences in the communication protocols between the two systems (for example, there are certain differences in the format of carrying request parameters). Therefore, in order to facilitate the Jenkins system to receive and execute the merge request sent by the Codehub system, a transit web service can be built to receive the merge request from Codehub and trigger the Jenkins system to execute the merge task. For example, the URL address of the transit web service is "http://zhongzhuan.com".
本申请实施例中的代码评审平台可以是上述Codehub系统或者gerrit系统,用于实现对代码的评审并发起合并请求,以请求将评审通过的目标代码合并至源代码中。中转平台可以是通过软件搭建的中转Web服务,用于作为代码评审平台与项目构建平台之间的中转节点,用于将代码评审平台发送的第一合并请求,转换为项目构建平台能够解析的第二合并请求。项目构建平台可以是上述Jenkins系统,用于根据合并请求,获取目标代码与源代码进行合并后编译,并在编译成功后,打包得到软件包存储。The code review platform in the embodiment of the present application may be the above-mentioned Codehub system or gerrit system, which is used to implement the review of the code and initiate a merge request to request that the target code that has passed the review be merged into the source code. The transit platform may be a transit Web service built by software, which is used as a transit node between the code review platform and the project construction platform, and is used to convert the first merge request sent by the code review platform into a second merge request that can be parsed by the project construction platform. The project construction platform may be the above-mentioned Jenkins system, which is used to obtain the target code and the source code according to the merge request, merge and compile them, and after successful compilation, package and store the software package.
可以理解,上述代码管理系统中每个平台,可以部署在不同的计算设备中,每个计算设备通过通信连接。或者,上述代码管理系统中每个平台,都可以部署在同一个计算设备中。又或者,上述代码管理系统中某一个平台可以部署在一个计算设备中,其他两个平台可以部署在另一个计算设备中。本申请实施例对此具体实现不作限制。It is understandable that each platform in the above code management system can be deployed in different computing devices, and each computing device is connected by communication. Alternatively, each platform in the above code management system can be deployed in the same computing device. Alternatively, one platform in the above code management system can be deployed in one computing device, and the other two platforms can be deployed in another computing device. The embodiment of the present application does not limit this specific implementation.
本申请实施例提供的技术方案所应用的计算设备,具体可以是刀片服务器、高密服务器、机架服务器或高性能服务器等,或者通用服务器、图形处理器(graphicsprocessing unit,GPU)服务器、数据处理器(data processing unit,DPU)服务器或人工智能(artificial intelligence,AI)服务器等。The computing device used in the technical solution provided in the embodiments of the present application may specifically be a blade server, a high-density server, a rack server or a high-performance server, or a general-purpose server, a graphics processing unit (GPU) server, a data processing unit (DPU) server or an artificial intelligence (AI) server, etc.
图3为本申请实施例提供的一种代码管理方法的流程示意图。示例性的,本申请实施例提供的代码管理方法,可以应用于图1或图2所示的代码管理系统的项目构建平台中。Fig. 3 is a flow chart of a code management method provided in an embodiment of the present application. Exemplarily, the code management method provided in an embodiment of the present application can be applied to the project construction platform of the code management system shown in Fig. 1 or Fig. 2.
如图3所示,本申请实施例提供的代码管理方法具体可以包括以下步骤:As shown in FIG3 , the code management method provided in the embodiment of the present application may specifically include the following steps:
S301、接收代码评审平台的合并请求。S301. Receive a merge request from the code review platform.
其中,合并请求用于请求合并目标代码与源代码。Among them, the merge request is used to request to merge the target code and the source code.
在本申请实施例中,若开发人员完成了目标代码的编写,需要将目标代码合并到源代码上,通过将目标代码合并到源代码,实现诸如对源代码的功能补充或者漏洞修复等操作,则开发人员可以在代码评审平台上进行操作,使得代码评审平台向项目构建平台发起合并请求。In an embodiment of the present application, if the developer has completed the writing of the target code and needs to merge the target code into the source code, by merging the target code into the source code, operations such as supplementing the function of the source code or fixing vulnerabilities can be implemented. The developer can perform operations on the code review platform, so that the code review platform initiates a merge request to the project construction platform.
作为一种示例,合并请求中包括如下参数:合并补丁的信息、目标代码的仓库地址以及配置文件的仓库地址。可选的,合并请求中还可以包括MR标题、目标代码的分支标识、源代码的分支标识、MR发起人标识等。As an example, the merge request includes the following parameters: information of the merged patch, the repository address of the target code, and the repository address of the configuration file. Optionally, the merge request may also include the MR title, the branch identifier of the target code, the branch identifier of the source code, the MR initiator identifier, etc.
其中,MR标题可以用于描述本次代码合并的内容,方便其他开发人员了解本次合并的目的。示例性的,MR标题为“本次修复了xxx故障”,用于指示本次合并的目的是对xxx故障的修复操作。The MR title can be used to describe the content of this code merge, so that other developers can understand the purpose of this merge. For example, the MR title is "This time fixes xxx fault", which is used to indicate that the purpose of this merge is to repair the xxx fault.
目标代码的仓库地址是存储目标代码的存储空间的地址,如前所述,代码管理系统是支持多个开发人员协同开发的。因此,每个开发人员都会在自己的用户侧设备上创建一个用于存储目标代码的存储空间(称目标仓库)。同时目标代码也可能存在多个版本,即目标代码具有多个不同分支,例如针对同一个功能的实现开发人员分别编写了两种实现方式,则可以对应目标代码的两个分支。在需要进行合并时,开发人员就会通过代码评审平台发送合并请求以通知项目构建平台需要合并的目标代码所在的目标仓库地址,使得项目构建平台可以基于该目标仓库地址从目标仓库中下载目标代码进行合并。可选的,合并请求中还可以指示目标代码的分支标识,使得项目构建平台可以根据分支标识获取对应的分支上的目标代码。The warehouse address of the target code is the address of the storage space where the target code is stored. As mentioned above, the code management system supports collaborative development by multiple developers. Therefore, each developer will create a storage space (called a target warehouse) on his or her own user-side device to store the target code. At the same time, there may be multiple versions of the target code, that is, the target code has multiple different branches. For example, for the implementation of the same function, the developer has written two implementation methods respectively, which can correspond to two branches of the target code. When a merge is required, the developer will send a merge request through the code review platform to notify the project construction platform of the target warehouse address where the target code to be merged is located, so that the project construction platform can download the target code from the target warehouse based on the target warehouse address for merging. Optionally, the branch identifier of the target code can also be indicated in the merge request, so that the project construction platform can obtain the target code on the corresponding branch according to the branch identifier.
合并补丁的信息,可以用于项目构建平台获取合并补丁。合并补丁可以是一种工具和一个步骤执行顺序,用于执行将目标代码合并到源代码上,具体可以合并到源代码的某个分支。合并补丁还可以针对合并请求生成唯一标识符(MR号),开发人员可以根据该MR号查询对应合并请求的相关信息。应理解,合并补丁的信息可以是合并补丁的存储地址,也可以是其他用于指示项目构建平台获取合并补丁的参数,例如合并补丁的标识等。The information of the merge patch can be used by the project build platform to obtain the merge patch. The merge patch can be a tool and a step execution sequence, which is used to merge the target code into the source code, specifically into a branch of the source code. The merge patch can also generate a unique identifier (MR number) for the merge request, and the developer can query the relevant information of the corresponding merge request based on the MR number. It should be understood that the information of the merge patch can be the storage address of the merge patch, or other parameters used to instruct the project build platform to obtain the merge patch, such as the identifier of the merge patch.
源代码的分支标识指示待并入目标代码的源代码的分支,基于合并请求中源代码的分支标识,可以确定需要将目标代码并入到源代码的哪个分支,一般为主分支。The branch identifier of the source code indicates the branch of the source code to be merged into the target code. Based on the branch identifier of the source code in the merge request, it can be determined which branch of the source code the target code needs to be merged into, generally the main branch.
配置文件的仓库地址用于指示配置文件的存储位置,其中,配置文件用于指示代码的执行顺序,代码运行过程中需要的依赖包、编译器等内容,是代码进行编译时必不可少的因素。The repository address of the configuration file is used to indicate the storage location of the configuration file. The configuration file is used to indicate the execution order of the code, the dependency packages, compilers, etc. required during the code running process, which are essential factors for compiling the code.
MR发起人标识可以方便其他开发人员查看是谁发起了此次合并请求。另外,MR发起人标识也可以用于归档软件包,即针对发起人不同创建不同的目录用于存储对应的软件包,方便对软件包的统一管理。The MR initiator ID can help other developers check who initiated the merge request. In addition, the MR initiator ID can also be used to archive software packages, that is, different directories are created for different initiators to store corresponding software packages, which facilitates unified management of software packages.
在一种实现方式中,在项目构建平台通过中转平台与代码评审平台连接时,上述S301可以实现为:接收中转平台第二合并请求;第二合并请求为中转平台对代码评审平台发送的第一合并请求处理后的请求。其中,第一合并请求是符合HTTP协议规定格式的请求,第二合并请求是符合项目构建平台规定格式的请求。In one implementation, when the project construction platform is connected to the code review platform through the transit platform, the above S301 can be implemented as follows: receiving a second merge request from the transit platform; the second merge request is a request after the transit platform processes the first merge request sent by the code review platform. The first merge request is a request in a format that complies with the HTTP protocol, and the second merge request is a request in a format that complies with the project construction platform.
其中,代码评审平台中的网络钩子(WebHook)模块,支持基于开发人员的指令对指定的URL(中转平台的地址)发起第一合并请求。进一步的,中转平台根据第一合并请求中携带的参数,向项目构建平台发送第二合并请求,以使得项目构建平台执行代码合并与编译等流程。Among them, the webhook module in the code review platform supports initiating a first merge request to a specified URL (the address of the transfer platform) based on the developer's instructions. Furthermore, the transfer platform sends a second merge request to the project construction platform based on the parameters carried in the first merge request, so that the project construction platform executes processes such as code merging and compilation.
示例性的,中转平台可以解析第一合并请求,提取第一合并请求中请求体的参数,构建符合项目构建平台规定格式的第二合并请求,并发送至项目构建平台。Exemplarily, the transit platform may parse the first merge request, extract the parameters of the request body in the first merge request, construct a second merge request that complies with the format specified by the project construction platform, and send it to the project construction platform.
S302、响应于合并请求,合并目标代码与源代码得到第一代码。S302: In response to the merge request, merge the target code and the source code to obtain a first code.
S303、编译第一代码。S303: Compile the first code.
S304、在第一代码编译验证成功后,基于目标代码更新源代码得到第二代码。S304: After the first code is compiled and verified successfully, the source code is updated based on the target code to obtain a second code.
针对上述S302-S304,在本申请实施例中,在接收到合并请求后,响应于合并请求,项目构建平台可以获取目标代码和源代码,合并目标代码和源代码得到第一代码。进而运行该第一代码进行编译,根据编译结果判断目标代码是否存在问题。若编译结果无问题,则更新源代码得到第二代码(即代码入库的过程),以便于后续将第二代码部署到指定的测试环境或生成环境中使用。For S302-S304 above, in an embodiment of the present application, after receiving a merge request, in response to the merge request, the project construction platform can obtain the target code and the source code, merge the target code and the source code to obtain the first code. Then run the first code for compilation, and judge whether there is a problem with the target code according to the compilation result. If there is no problem with the compilation result, the source code is updated to obtain the second code (i.e., the process of code storage), so that the second code can be deployed to a specified test environment or a production environment for use later.
在一种实现方式中,若编译结果存在问题,则禁止当前的目标代码入库(即不更新源代码),向合并请求的发起者返回问题相关信息,使得发起者对目标代码做进一步修改。In one implementation, if there is a problem with the compilation result, the current target code is prohibited from being stored (ie, the source code is not updated), and information related to the problem is returned to the initiator of the merge request so that the initiator can make further modifications to the target code.
其中,S302中合并的过程具体参见下述图4对应的描述,S303中编译的过程具体参见下述图5对应的描述。For details of the merging process in S302, please refer to the description corresponding to FIG. 4 below. For details of the compiling process in S303, please refer to the description corresponding to FIG. 5 below.
S305、在合并请求指示生成软件包的情况下,基于第二代码生成软件包。S305: When the merge request indicates to generate a software package, generate the software package based on the second code.
在本申请实施例中,项目构建平台判断合并请求中指示生成软件包,若合并请求指示生成归档软件包,则执行将第二代码打包为软件包的过程。另外,还可以对软件包进行存储,方便第一代码后续在其他设备上的测试运行。可以看出,在开发人员不存在生成软件包的需求情况下,项目构建平台在第一代码验证通过后,可以将更新得到的第二代码生成软件包,无需用户额外执行打包的操作,从而提高代码管理系统的处理效率。In an embodiment of the present application, the project construction platform determines that the merge request indicates the generation of a software package. If the merge request indicates the generation of an archived software package, the process of packaging the second code into a software package is executed. In addition, the software package can also be stored to facilitate the subsequent testing and running of the first code on other devices. It can be seen that when the developer does not have the need to generate a software package, the project construction platform can generate a software package for the updated second code after the first code is verified, without the user having to perform additional packaging operations, thereby improving the processing efficiency of the code management system.
示例性的,第一合并请求是否指示生成软件包,可以通过如下方式确定:Exemplarily, whether the first merge request indicates to generate a software package may be determined in the following manner:
若合并请求中包括第一字段(例如开发人员在输入MR标题时,在MR标题中携带“生成软件包”的字段),或者包括第二字段(例如开发人员在输入MR标题时,在MR标题中携带“不生成软件包”的字段),则说明本次合并过程中代码管理系统需要生成软件包以进行存储。If the merge request includes the first field (for example, when the developer enters the MR title, the MR title carries the field of "generate software package"), or includes the second field (for example, when the developer enters the MR title, the MR title carries the field of "do not generate software package"), it means that the code management system needs to generate a software package for storage during this merge process.
若合并请求中没有包括第一字段或第二字段,则说明本次合并过程中代码管理系统不需要生成软件包,则项目构建平台在接收到合并请求后,可以执行上述S302而不执行S303。可以看出,在开发人员不存在生成软件包的需求情况下,项目构建平台仅对第一代码进行编译验证以及代码入库,不会执行打包生成软件包的过程。这样可以减少生成软件包的过程所花费的时间,提高代码管理系统的处理效率。另外,根据合并请求中的内容实现软件包的按需生成并归档,而不是无差别的生成并存储所有合并请求对应的软件包,可以避免存储资源的浪费。If the merge request does not include the first field or the second field, it means that the code management system does not need to generate a software package during this merge process. After receiving the merge request, the project construction platform can execute the above S302 instead of S303. It can be seen that when the developer does not have the need to generate a software package, the project construction platform only compiles and verifies the first code and stores the code in the library, and does not execute the process of packaging and generating the software package. This can reduce the time spent in the process of generating the software package and improve the processing efficiency of the code management system. In addition, the on-demand generation and archiving of the software package according to the content in the merge request, rather than indiscriminately generating and storing the software packages corresponding to all merge requests, can avoid the waste of storage resources.
在一种实现方式中,合并请求包括:目标代码的仓库地址以及合并补丁的信息。合并补丁用于将目标代码与源代码合并以得到第一代码。上述S302中合并目标代码与源代码得到第一代码,如图4所示,可以实现为如下:In one implementation, the merge request includes: the repository address of the target code and information of the merge patch. The merge patch is used to merge the target code with the source code to obtain the first code. The merge of the target code with the source code to obtain the first code in S302 above can be implemented as follows, as shown in FIG4:
S401、根据目标代码的仓库地址,下载目标代码至本地代码仓库。其中,本地代码仓库为项目构建平台中用于存储代码的存储空间,本地代码仓库中还包括源代码。S401, downloading the target code to the local code warehouse according to the warehouse address of the target code, wherein the local code warehouse is a storage space for storing codes in the project construction platform, and the local code warehouse also includes source code.
S402、根据合并补丁的信息,获取合并补丁。S402: Obtain a merged patch according to information of the merged patch.
S403、将合并补丁配置到本地代码仓库中,以完成目标代码与源代码的合并,得到第一代码。S403: deploy the merged patch into the local code repository to complete the merging of the target code and the source code to obtain the first code.
示例性的,项目构建平台解析合并请求,获取目标代码的仓库地址。基于该仓库地址通过网络请求访问到存储目标代码的仓库,下载对应的目标代码(若合并请求中指导了目标代码的分支标识,可以下载对应分支上的目标代码)到项目构建平台自身的创建的本地代码仓库中。进一步的,项目构建平台根据源代码的分支和合并补丁的信息获取合并补丁,并配置合并补丁到本地代码仓库。如前所述,合并补丁为将目标代码与源代码合并的工具,通过项目构建平台在获取合并补丁并配置到本地代码仓库后,合并补丁就可以运行,实现读取已下载到本地代码仓库中的目标代码,并合到源代码上(若合并请求中指示了源代码的分支标识,则可以根据该分支标识获取对应的合并补丁,实现将目标代码合并到制定分支的源代码上),得到合并后的第一代码。Exemplarily, the project construction platform parses the merge request and obtains the warehouse address of the target code. Based on the warehouse address, the warehouse storing the target code is accessed through a network request, and the corresponding target code is downloaded (if the branch identifier of the target code is instructed in the merge request, the target code on the corresponding branch can be downloaded) to the local code warehouse created by the project construction platform itself. Furthermore, the project construction platform obtains the merge patch based on the branch of the source code and the information of the merge patch, and configures the merge patch to the local code warehouse. As mentioned above, the merge patch is a tool for merging the target code with the source code. After the project construction platform obtains the merge patch and configures it to the local code warehouse, the merge patch can be run to read the target code downloaded to the local code warehouse and merge it to the source code (if the branch identifier of the source code is indicated in the merge request, the corresponding merge patch can be obtained according to the branch identifier to merge the target code to the source code of the specified branch), and the first merged code is obtained.
在一种实现方式中,合并请求还包括:配置文件的仓库地址。上述S303中编译第一代码,如图5所示,可以实现为如下:In one implementation, the merge request also includes: the repository address of the configuration file. Compiling the first code in S303 above, as shown in FIG5 , can be implemented as follows:
S501、根据配置文件的仓库地址,下载配置文件至本地配方仓库。其中,本地配方仓库为项目构建平台中用于存储配置文件的存储空间。S501. Download the configuration file to the local recipe warehouse according to the warehouse address of the configuration file. The local recipe warehouse is a storage space in the project construction platform for storing configuration files.
S502、根据目标代码的仓库地址,从本地配方仓库中确定对应的目标配置文件。S502: According to the warehouse address of the target code, determine the corresponding target configuration file from the local recipe warehouse.
S503、修改目标配置文件中用于索引代码的地址为本地代码仓库的地址。S503: Modify the address for indexing the code in the target configuration file to the address of the local code repository.
S504、在本地配方仓库中对第一代码进行编译。S504: Compile the first code in the local recipe repository.
应理解,得到第一代码后,项目构建平台还需要对第一代码进行编译以运行,以使第一代码可以实现预期的功能。另外,前面提到,代码的运行需要依赖运行环境(如需要某些依赖包才能正常运行)。因此,项目构建平台可以根据配置文件的仓库地址,访问到存储配置文件的配方仓库,并下载配置文件至本地配方仓库。进一步的,从配置文件中查询用于索引代码位置的目标配置文件,将目标配置文件中用于索引代码的地址修改为本地代码仓库的地址,然后项目构建平台在本地配方仓库中执行代码编译命令,使得配置文件可以运行以搭建运行环境,并根据目标配置文件的地址从本地代码仓库中读取第一代码进行编译。It should be understood that after obtaining the first code, the project construction platform also needs to compile the first code to run so that the first code can achieve the expected function. In addition, as mentioned above, the operation of the code needs to rely on the operating environment (such as certain dependent packages are required to run normally). Therefore, the project construction platform can access the recipe warehouse storing the configuration file according to the warehouse address of the configuration file, and download the configuration file to the local recipe warehouse. Further, the target configuration file for indexing the code location is queried from the configuration file, and the address for indexing the code in the target configuration file is modified to the address of the local code warehouse, and then the project construction platform executes the code compilation command in the local recipe warehouse, so that the configuration file can run to build the operating environment, and read the first code from the local code warehouse according to the address of the target configuration file for compilation.
可以理解,若第一代码编译成功,则说明本次合并中开发人员编写的目标代码无问题,则项目构建平台允许代码入库,即基于目标代码更新源代码。相对的,若第一代码编译失败,则说明本次合并中开发人员编写的目标代码存在问题,则项目构建平台禁止代码入库,将编译失败对应的报错问题反馈至开发人员,使得开发人员可以对目标代码基于报错问题对目标代码做重新修改。It can be understood that if the first code is compiled successfully, it means that there is no problem with the target code written by the developer in this merger, and the project construction platform allows the code to be stored, that is, the source code is updated based on the target code. Conversely, if the first code fails to compile, it means that there is a problem with the target code written by the developer in this merger, and the project construction platform prohibits the code from being stored, and feedbacks the error corresponding to the compilation failure to the developer, so that the developer can modify the target code based on the error.
应理解,目标代码存储在开发人员的用户侧设备的目标仓库中,在有需要的时候项目构建平台可以访问到目标仓库并下载使用,可以实现项目的分布式开发,提高项目开发效率。另外,项目构建平台可以通过配置文件,合并补丁等脚本配置的方式依次执行编译步骤,无需人工参与,提高开发效率。It should be understood that the target code is stored in the target warehouse of the developer's user-side device. When necessary, the project construction platform can access the target warehouse and download it for use, which can realize the distributed development of the project and improve the efficiency of project development. In addition, the project construction platform can execute the compilation steps in sequence through script configuration such as configuration files and merge patches, without manual participation, thus improving development efficiency.
相关方案中,在存在生成软件包的需求时,需要开发人员手动配置软件包的包名,这需要额外的人工操作,影响效率。本申请实施例提供的代码管理方法,以目标代码的仓库地址反推出与之对应的配置文件及软件包名,自动完成软件包的生成,具体描述如下:In related solutions, when there is a need to generate a software package, the developer needs to manually configure the package name of the software package, which requires additional manual operations and affects efficiency. The code management method provided in the embodiment of the present application uses the warehouse address of the target code to infer the corresponding configuration file and software package name, and automatically completes the generation of the software package, which is specifically described as follows:
在一种实现方式中,上述S305中将第二代码打包,生成软件包,包括:1、获取配置文件。2、从配置文件中确定目标代码对应的目标配置文件。3、根据目标配置文件的文件名确定软件包的包名。4、基于包名将第二代码打包,生成软件包。In one implementation, the second code is packaged to generate a software package in S305, including: 1. Obtaining a configuration file. 2. Determining a target configuration file corresponding to the target code from the configuration file. 3. Determining a package name of the software package according to the file name of the target configuration file. 4. Packaging the second code based on the package name to generate a software package.
其中,获取配置文件以及确定目标配置文件的具体过程,可以参见上述实现方式中的描述,在此不再重复赘述。The specific process of obtaining the configuration file and determining the target configuration file can be found in the description of the above implementation, and will not be repeated here.
应理解,代码在打包时,需要开发人员指定软件包的包名以便于归档存储。但是一般情况下,软件包所配置的包名是与源代码对应的项目名称有关,且包含当前项目对应的版本等信息。这就需要开发人员手动查询源代码的相关信息以确定包名,操作较为繁琐。考虑到目标配置文件的作用是描述代码生成软件包的方式,其命名与项目名称强相关。因此,本申请实施例中项目构建平台基于目标配置文件提取包名,并基于包名执行打包命令(例如bitbake的命令,也可以是其他用于打包的命令)将第二代码打包为软件包,并将软件包存储起来,实现无需开发人员参与自动完成软件包生成与归档。It should be understood that when the code is packaged, the developer needs to specify the package name of the software package for archiving and storage. However, in general, the package name configured by the software package is related to the project name corresponding to the source code, and contains information such as the version corresponding to the current project. This requires the developer to manually query the relevant information of the source code to determine the package name, and the operation is relatively cumbersome. Considering that the role of the target configuration file is to describe the way the code generates the software package, its naming is strongly related to the project name. Therefore, in the embodiment of the present application, the project construction platform extracts the package name based on the target configuration file, and executes a packaging command (such as a bitbake command, or other commands for packaging) based on the package name to package the second code as a software package, and the software package is stored, so that the software package generation and archiving are automatically completed without the need for the developer to participate.
示例性的,以OpenBMC项目为例,其对应的目标配置文件的文件格式为bb类型或者bbappend类型。这两种文件的命名通常遵循一定的约定和规范,以确保项目的可维护性和清晰性,方便开发人员进行管理和识别。另外,考虑下划线以及某些通配符会与操作系统的关键字符冲突,因此在生成软件包时还要确保软件包的包名中不包括此类字符。因此,针对bb类型的文件,去掉文件名中的“_”即可得到对应的软件包的包名。针对bbappend类型的文件,去掉文件名中的“_”和通配符之后即可得到对应的软件包的包名。在确定包名之后,项目构建平台可以采用打包命令,基于包名将第一代码打包为软件包。Exemplarily, taking the OpenBMC project as an example, the file format of the corresponding target configuration file is bb type or bbappend type. The naming of these two files usually follows certain conventions and specifications to ensure the maintainability and clarity of the project, and to facilitate management and identification by developers. In addition, considering that underscores and certain wildcards will conflict with key characters of the operating system, it is also necessary to ensure that such characters are not included in the package name of the software package when generating the software package. Therefore, for files of type bb, the package name of the corresponding software package can be obtained by removing the "_" in the file name. For files of type bbappend, the package name of the corresponding software package can be obtained by removing the "_" and wildcard in the file name. After determining the package name, the project construction platform can use a packaging command to package the first code into a software package based on the package name.
应理解,软件包的存储位置可以是预设的本地位置,也可以是预设的云端位置,本申请实施例对此不作具体限制。另外,在软件包归档存储的过程中,可以根据发起人的标识进行归档,方便确定当前合并得到的软件包对应的开发人员,以便于后续可以通知到对应的开发人员进行维护。It should be understood that the storage location of the software package can be a preset local location or a preset cloud location, and the present application embodiment does not impose specific restrictions on this. In addition, during the process of archiving and storing the software package, it can be archived according to the initiator's identification, which is convenient for determining the developer corresponding to the currently merged software package, so that the corresponding developer can be notified to perform maintenance later.
在一些场景中,本申请实施例的技术方案是以合并请求中MR标题中的关键字为例进行说明的,开发人员在发起合并请求时可以通过编辑MR标题,来确定当前操作是否要进行软件包的存储。可选的,还可以在代码评审平台上开发一个功能,当需要发起合并请求时,显示一个控件,若开发人员点击了该控件,则项目构建平台在进行代码合并时会生成软件包并归档保存,默认状态下则不会生成软件包并保存。In some scenarios, the technical solution of the embodiment of the present application is explained by taking the keywords in the MR title in the merge request as an example. When initiating a merge request, the developer can edit the MR title to determine whether the current operation is to store the software package. Optionally, a function can be developed on the code review platform to display a control when a merge request needs to be initiated. If the developer clicks the control, the project construction platform will generate a software package and archive it when merging the code. In the default state, the software package will not be generated and saved.
图6为本申请实施例体提供的一种合并事件执行流程图。如图5所示,首先,1、发起合并请求。2、中转平台将合并请求转发至项目构建平台。3、下载目标代码至本地代码仓库。4、下载合并补丁配置到本地代码仓库。5、下载配置文件,修改目标配置文件中的用于索引代码地址。6、基于目标配置文件确定软件包的包名。7、进行编译。在编译不成功时,8、拦截代码入库并结束。在编译成功时,9、执行代码入库。进一步判断,10、合并请求中是否指示生成软件包。若指示,11、生成软件包并归档。若不指示,12、退出流程。Figure 6 is a merge event execution flow chart provided by an embodiment of the present application. As shown in Figure 5, first, 1. Initiate a merge request. 2. The transit platform forwards the merge request to the project construction platform. 3. Download the target code to the local code repository. 4. Download the merge patch configuration to the local code repository. 5. Download the configuration file and modify the address used to index the code in the target configuration file. 6. Determine the package name of the software package based on the target configuration file. 7. Compile. When the compilation is unsuccessful, 8. Intercept the code from being stored in the library and end. When the compilation is successful, 9. Execute the code from being stored in the library. Further judge, 10. Whether the merge request indicates to generate a software package. If indicated, 11. Generate a software package and archive it. If not indicated, 12. Exit the process.
本申请实施例提供一种代码管理方法,该方法中项目构建平台可以接收并响应于代码评审平台的合并请求,并执行代码的合并以及编译验证后,可以在合并请求指示归档生成软件包的情况下,进一步基于对更新得到的第二代码打包,以生成软件包。可以看出,本申请实施例提供的方法中,项目构建平台可以基于合并请求的指示,按需执行对第二代码打包生成软件包的步骤。这样可以避免项目构建平台无差别的对每次合并请求生成的代码打包,浪费计算资源的同时增加了处理流程,影响项目构建平台的处理效率。另外,在开发人员存在生成软件包的需求时,无需开发人员手动通过命令配置以使得项目构建平台执行打包的过程,降低开发人员使用项目构建平台的技术门槛。The embodiment of the present application provides a code management method, in which the project construction platform can receive and respond to the merge request of the code review platform, and after executing the merge and compilation verification of the code, it can be further based on the second code package obtained by the update to generate the software package when the merge request indicates the archive generation software package. It can be seen that in the method provided by the embodiment of the present application, the project construction platform can perform the step of packaging the second code to generate the software package on demand based on the instruction of the merge request. This can avoid the project construction platform from packaging the code generated by each merge request indiscriminately, and wastes computing resources while increasing the processing flow, affecting the processing efficiency of the project construction platform. In addition, when the developer has the need to generate a software package, there is no need for the developer to manually configure the command so that the project construction platform executes the process of packaging, reducing the technical threshold for developers to use the project construction platform.
进一步的,本申请实施例提供的代码管理方法,项目构建平台可以自主基于目标代码仓库的地址反推出与之对应的配置文件,并基于配置文件确定软件包的包名,无需开发人员手动编辑包名,进一步提高代码管理系统的处理效率。Furthermore, in the code management method provided in the embodiment of the present application, the project construction platform can independently infer the corresponding configuration file based on the address of the target code repository, and determine the package name of the software package based on the configuration file, without the need for developers to manually edit the package name, thereby further improving the processing efficiency of the code management system.
可以看出,上述主要从方法的角度对本申请实施例提供的方案进行了介绍。为了实现上述功能,本申请实施例提供了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的模块及算法步骤,本申请实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。It can be seen that the above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, the embodiment of the present application provides a hardware structure and/or software module corresponding to each function. Those skilled in the art should easily appreciate that, in combination with the modules and algorithm steps of each example described in the embodiment disclosed herein, the embodiment of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
在示例性的实施例中,本申请还提供一种代码管理装置。该代码管理装置可以应用于前述项目构建平台中。该代码管理装置可以包括一个或多个功能模块,用于实现以上方法实施例的代码管理方法。In an exemplary embodiment, the present application further provides a code management device. The code management device can be applied to the aforementioned project construction platform. The code management device can include one or more functional modules for implementing the code management method of the above method embodiment.
例如,图7为本申请实施例提供的一种代码管理装置的组成示意图。如图7所示,该代码管理装置包括:接收模块701以及处理模块702。接收模块701与处理模块702连接。For example, Fig. 7 is a schematic diagram of the composition of a code management device provided in an embodiment of the present application. As shown in Fig. 7, the code management device includes: a receiving module 701 and a processing module 702. The receiving module 701 is connected to the processing module 702.
接收模块701用于,接收合并请求;所述合并请求用于请求合并目标代码与源代码并且指示是否生成软件包;所述软件包包括所述目标代码与所述源代码,以及支持所述目标代码和所述源代码运行的运行环境;The receiving module 701 is used to receive a merge request; the merge request is used to request to merge the target code and the source code and indicate whether to generate a software package; the software package includes the target code and the source code, and an operating environment that supports the operation of the target code and the source code;
处理模块702用于,响应于合并请求,合并目标代码与源代码得到第一代码;The processing module 702 is used to, in response to the merge request, merge the target code and the source code to obtain the first code;
处理模块702还用于,编译第一代码;The processing module 702 is further used to compile the first code;
处理模块702还用于,在第一代码编译验证成功后,基于目标代码更新源代码得到第二代码;The processing module 702 is also used to update the source code based on the target code to obtain the second code after the first code is successfully compiled and verified;
处理模块702还用于,在合并请求指示生成软件包的情况下,将第二代码打包,生成软件包。The processing module 702 is further configured to package the second code to generate a software package when the merge request indicates to generate a software package.
在一些实施方式中,在合并请求包括第一字段的情况下,或者在合并请求未包括第二字段的情况下,合并请求用于指示生成软件包;其中,第一字段为用于指示生成软件包的字段,第二字段为用于指示不生成软件包的字段。In some implementations, when the merge request includes a first field, or when the merge request does not include a second field, the merge request is used to indicate generation of a software package; wherein the first field is a field used to indicate generation of a software package, and the second field is a field used to indicate not generation of a software package.
在一些实施方式中,处理模块702具体用于,获取配置文件;配置文件为用于支持源代码运行的文件;从配置文件中确定目标配置文件;目标配置文件用于指示基于代码生成软件包的方式;根据目标配置文件的文件名确定软件包的包名;基于包名将第二代码打包,生成软件包。In some embodiments, the processing module 702 is specifically used to obtain a configuration file; the configuration file is a file used to support the running of the source code; determine a target configuration file from the configuration file; the target configuration file is used to indicate a method for generating a software package based on the code; determine a package name of the software package according to the file name of the target configuration file; and package the second code based on the package name to generate a software package.
在一些实施方式中,合并请求包括:目标代码的仓库地址和合并补丁的信息;合并补丁用于将目标代码与源代码合并以得到第一代码;处理模块702具体用于,根据目标代码的仓库地址,下载目标代码至本地代码仓库;本地代码仓库为项目构建平台中用于存储代码的存储空间,本地代码仓库中还包括源代码;根据合并补丁的信息,获取合并补丁;将合并补丁配置到本地代码仓库中,以完成目标代码与源代码的合并,得到第一代码。In some embodiments, the merge request includes: the repository address of the target code and the information of the merge patch; the merge patch is used to merge the target code with the source code to obtain the first code; the processing module 702 is specifically used to download the target code to the local code repository according to the repository address of the target code; the local code repository is a storage space for storing code in the project construction platform, and the local code repository also includes source code; according to the information of the merge patch, obtain the merge patch; configure the merge patch to the local code repository to complete the merge of the target code and the source code to obtain the first code.
在一些实施方式中,合并请求还包括:配置文件的仓库地址;处理模块702具体用于,根据配置文件的仓库地址,下载配置文件至本地配方仓库;本地配方仓库为项目构建平台中用于存储配置文件的存储空间;根据目标代码的仓库地址,从本地配方仓库中确定对应的目标配置文件;修改目标配置文件中用于索引代码的地址为本地代码仓库的地址;在本地配方仓库中对第一代码进行编译。In some embodiments, the merge request also includes: the repository address of the configuration file; the processing module 702 is specifically used to download the configuration file to the local recipe repository according to the repository address of the configuration file; the local recipe repository is a storage space for storing configuration files in the project construction platform; according to the repository address of the target code, determining the corresponding target configuration file from the local recipe repository; modifying the address for indexing the code in the target configuration file to the address of the local code repository; and compiling the first code in the local recipe repository.
在一些实施方式中,项目构建平台通过中转平台与代码评审平台连接;接收模块701具体用于,接收中转平台第二合并请求;第二合并请求为中转平台对代码评审平台发送的第一合并请求处理后的请求;其中,第一合并请求是符合超文本传输协议规定格式的请求,第二合并请求是符合项目构建平台规定格式的请求。In some embodiments, the project construction platform is connected to the code review platform via a transit platform; the receiving module 701 is specifically used to receive a second merge request from the transit platform; the second merge request is a request after the transit platform processes the first merge request sent by the code review platform; wherein, the first merge request is a request in a format that complies with the Hypertext Transfer Protocol, and the second merge request is a request in a format that complies with the project construction platform.
在示例性的实施例中,本申请实施例还提供了一种计算设备。图8为本申请实施例提供的计算设备的组成示意图。如图8所示,该计算设备可以包括:处理器801和存储器802;存储器802存储有处理器808可执行的指令;处理器801被配置为执行指令时,使得计算设备实现如前述方法实施例中描述的方法。In an exemplary embodiment, the present application also provides a computing device. FIG8 is a schematic diagram of the composition of the computing device provided in the present application. As shown in FIG8, the computing device may include: a processor 801 and a memory 802; the memory 802 stores instructions executable by the processor 808; when the processor 801 is configured to execute the instructions, the computing device implements the method described in the aforementioned method embodiment.
本申请实施例还提供了一种计算机可读存储介质。上述方法实施例中的全部或者部分流程可以由计算机指令来指示相关的硬件完成,该程序可存储于上述计算机可读存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。计算机可读存储介质可以是前述任一实施例的或内存。上述计算机可读存储介质也可以是上述恢复装置的外部存储设备,例如上述恢复装置上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flashcard)等。进一步地,上述计算机可读存储介质还可以既包括上述恢复装置的内部存储单元也包括外部存储设备。上述计算机可读存储介质用于存储上述计算机程序以及上述恢复装置所需的其他程序和数据。上述计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。The embodiment of the present application also provides a computer-readable storage medium. All or part of the processes in the above method embodiment can be completed by computer instructions to instruct the relevant hardware, and the program can be stored in the above computer-readable storage medium. When the program is executed, it may include the processes of the above method embodiments. The computer-readable storage medium can be any of the above embodiments or memory. The above computer-readable storage medium can also be an external storage device of the above recovery device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flashcard), etc. equipped on the above recovery device. Further, the above computer-readable storage medium can also include both the internal storage unit of the above recovery device and an external storage device. The above computer-readable storage medium is used to store the above computer program and other programs and data required for the above recovery device. The above computer-readable storage medium can also be used to temporarily store data that has been output or is to be output.
本申请实施例还提供一种计算机程序产品,该计算机产品包含计算机程序,当该计算机程序产品在计算机上运行时,使得该计算机执行上述实施例中所提供的任一项代码管理方法。An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program product is run on a computer, the computer is enabled to execute any one of the code management methods provided in the above embodiments.
尽管在此结合各实施例对本申请进行了描述,然而,在实施所要求保护的本申请过程中,本领域技术人员通过查看附图、公开内容、以及所附权利要求书,可理解并实现公开实施例的其他变化。在权利要求中,“包括”(Comprising)一词不排除其他组成部分或步骤,“一”或“一个”不排除多个的情况。单个处理器或其他单元可以实现权利要求中列举的若干项功能。相互不同的从属权利要求中记载了某些措施,但这并不表示这些措施不能组合起来产生良好的效果。Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "one" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in a claim. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
尽管结合具体特征及其实施例对本申请进行了描述,显而易见的,在不脱离本申请的精神和范围的情况下,可对其进行各种修改和组合。相应地,本说明书和附图仅仅是所附权利要求所界定的本申请的示例性说明,且视为已覆盖本申请范围内的任意和所有修改、变化、组合或等同物。显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
以上,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应该以权利要求的保护范围为准。The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410139893.1A CN118170420A (en) | 2024-01-31 | 2024-01-31 | A code management method, system and computing device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410139893.1A CN118170420A (en) | 2024-01-31 | 2024-01-31 | A code management method, system and computing device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118170420A true CN118170420A (en) | 2024-06-11 |
Family
ID=91349514
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410139893.1A Pending CN118170420A (en) | 2024-01-31 | 2024-01-31 | A code management method, system and computing device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118170420A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118689508A (en) * | 2024-06-17 | 2024-09-24 | 超聚变数字技术有限公司 | Software package updating method and computing device |
-
2024
- 2024-01-31 CN CN202410139893.1A patent/CN118170420A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118689508A (en) * | 2024-06-17 | 2024-09-24 | 超聚变数字技术有限公司 | Software package updating method and computing device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20210349706A1 (en) | Release lifecycle management system for multi-node application | |
WO2022170801A1 (en) | Ios application program construction method and apparatus, electronic device, and storage medium | |
CN109960643B (en) | Code testing method and device | |
US10114637B1 (en) | Automatically updating a shared project build platform | |
US10579966B1 (en) | Adapting a shared project build platform to a developer plugin | |
US8745585B2 (en) | Meta-data for single development test environment | |
US7937697B2 (en) | Method, system and computer program for distributing software patches | |
US20040060035A1 (en) | Automated method and system for building, deploying and installing software resources across multiple computer systems | |
US8352916B2 (en) | Facilitating the automated testing of daily builds of software | |
US20100162227A1 (en) | Automation of Mainframe Software Deployment | |
CN112685048B (en) | Application program packaging method, electronic device and storage medium | |
CN110727575B (en) | Information processing method, system, device and storage medium | |
CN112363731A (en) | Application automation deployment method and device and computer readable storage medium | |
CN114546819A (en) | Code processing method, apparatus, electronic device and readable medium | |
CN115145596A (en) | OTA (over the air) upgrading method and device for robot upgrading package | |
CN118170420A (en) | A code management method, system and computing device | |
WO2024174904A1 (en) | Management migration method and apparatus for container instance, and electronic device and storage medium | |
CN118540220A (en) | Remote upgrading method and system for terminal of Internet of things | |
CN117591412A (en) | Test method, test device, electronic equipment and storage medium | |
CN116244186A (en) | Operating system test management method and device and computing equipment | |
CN117472785B (en) | Openstack test method and system under Linux system | |
CN118445001B (en) | Heterogeneous system integration method, device and equipment based on plug-in development framework | |
CN117873650B (en) | Real-time running environment generation system, method, computer device and storage medium | |
CN112486631B (en) | Method for constructing virtual machine mirror image | |
CN118860577B (en) | Method, device, equipment, medium and product for updating status indication information |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |