CN114489676A - Source code processing method, system, storage medium and electronic equipment - Google Patents

Source code processing method, system, storage medium and electronic equipment Download PDF

Info

Publication number
CN114489676A
CN114489676A CN202210135551.3A CN202210135551A CN114489676A CN 114489676 A CN114489676 A CN 114489676A CN 202210135551 A CN202210135551 A CN 202210135551A CN 114489676 A CN114489676 A CN 114489676A
Authority
CN
China
Prior art keywords
item
compiled
source code
project
items
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
Application number
CN202210135551.3A
Other languages
Chinese (zh)
Inventor
雷经纬
徐嘉禛
翁晓俊
熊辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210135551.3A priority Critical patent/CN114489676A/en
Publication of CN114489676A publication Critical patent/CN114489676A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The application discloses a source code processing method, a source code processing system, a storage medium and electronic equipment. Relating to the field of financial science and technology, the method comprises the following steps: determining each project in the compiling task; acquiring the identification of a source code version library of each project, compiling branch information required by each project, and acquiring an interface of a distributed version control system; acquiring a source code of each item, and storing the source code of each item to a local compiling server; generating a list of items to be published according to the source codes of the items, preprocessing the items to be compiled in the list of the items to be published, and forming the list of the items to be compiled by the preprocessed items; compiling the items in the item list to be compiled to obtain a compiled product; and matching the compiled product with a preset deployment strategy, and generating a deployment strategy file of the compiled product under the condition of successful matching. By the method and the device, the problem of low system project construction and deployment efficiency in the related technology is solved.

Description

Source code processing method, system, storage medium and electronic equipment
Technical Field
The application relates to the field of financial science and technology, in particular to a source code processing method, a source code processing system, a storage medium and electronic equipment.
Background
The existing system project construction and deployment tool is composed of specific construction management tools according to project requirements, wherein part of general construction management tools comprise Ant (Apache Ant), Maven and Jenkins, and the Apache Ant is a standard open source construction tool suitable for Java projects. Ant uses an easily understandable XML (extensible Markup Language) Language as a configuration format, and is used for configuring specific parameters in a project construction process; maven is a software (especially a software project developed based on Java) project management and automatic construction tool. Maven also uses XML as a configuration format, but it also applies a unified object model (POM) -based concept, through which POM a central piece of information can be used to manage steps of construction, reporting, and documentation of a project. Jenkins is an open-source continuous integration tool, can be used for various automation tasks in software development, including construction, testing, deployment and the like, and is an important component of a system project construction and deployment toolchain. However, Ant, Maven and Jenkins can only finish the deployment or construction task of the project according to the project requirements, but cannot finish the construction and deployment task of the project.
The requirement of high-quality and short-period software version iteration on high automation of a system project construction and deployment process is more and more urgent, and for protecting a plurality of large Java projects which are correlated in a complex system, the requirements of the current system project construction and deployment on the efficiency, quality and automation of a construction tool cannot be met in a mode of Java project offline manual compilation and single-point manual deployment of a program installation package.
Aiming at the problem of low efficiency of system project construction and deployment in the related art, no effective solution is provided at present.
Disclosure of Invention
The application provides a source code processing method, a source code processing system, a storage medium and electronic equipment, which are used for solving the problem of low system project construction and deployment efficiency in the related art.
According to one aspect of the application, a method for processing source code is provided. The method comprises the following steps: determining each project in the compiling task; acquiring the identification of a source code version library of each project, compiling branch information required by each project, and acquiring an interface of a distributed version control system; according to the identification and the branch information, acquiring the source code of each item from a remote code hosting warehouse through an interface, and storing the source code of each item to a local compiling server; generating a to-be-published item list according to the source code of each item, preprocessing items to be compiled in the to-be-published item list to obtain preprocessed items, and forming the to-be-compiled item list by the preprocessed items; compiling the items in the item list to be compiled through a local compiling server to obtain a compiled product; and matching the compiled product with a preset deployment strategy, and generating a deployment strategy file of the compiled product under the condition of successful matching.
Optionally, after saving the source code of each item to the local compilation server, the method further comprises: detecting whether the source code accords with a source code management rule; under the condition that the source code accords with the source code management rule, executing a step of generating a list of items to be issued according to the source code of each item; and eliminating the source code under the condition that the source code does not accord with the source code management rule. By detecting the source code, the corresponding system can be adapted after the source code is processed.
Optionally, obtaining the source code of each item from the remote code hosting repository through the interface according to the identification and the branch information includes: judging whether a source code corresponding to the branch information of each project exists in the local compiling server; under the condition that the local compiling server does not have the source code corresponding to the branch information, all the source codes corresponding to the branch information are obtained from the remote code hosting warehouse; and acquiring the incremental source code corresponding to the branch information from the remote code hosting warehouse under the condition that the source code corresponding to the branch information exists in the local compiling server, wherein the incremental source code is different from the source code stored in the local compiling server. The source code is obtained through the incremental downloading mode and the full downloading mode, so that the local compiling server can be efficiently utilized, and bandwidth resources required by downloading the source code are not wasted.
Optionally, before preprocessing the item to be compiled in the to-be-published item list, the method further includes: judging whether an item in an item list to be issued is associated with preset mark information, wherein the preset mark information is used for indicating that the item needs to be compiled; and classifying the items in the item list to be issued according to whether the preset mark information is associated or not to obtain the items needing to be compiled and the items not needing to be compiled, wherein the items needing to be compiled are the items associated with the preset mark information, and the items not needing to be compiled are the items not associated with the preset mark information. By distinguishing whether the items need to be compiled or not, the local compiling server can not repeatedly compile to cause resource waste during compiling.
Optionally, the preprocessing the item to be compiled in the to-be-published item list includes: judging whether a dependency relationship exists between each item in the item list to be compiled and other items, wherein the other items are the items in the compiled item list; determining the item information of the item and marking a dependency relationship identifier under the condition that a dependency relationship does not exist between one item and other items; when the dependency relationship exists between one item and other items, determining the dependency item corresponding to the item, determining the information of the item and marking the dependency relationship identifier, and determining the item information of the dependency item and marking the dependency relationship identifier. By confirming the dependency relationship among the items, compiling errors caused by disordered compiling sequences of the items with the dependency relationship during compiling are avoided.
Optionally, the preprocessing the item to be compiled in the to-be-published item list further includes: judging whether each project in the project list to be compiled is an incremental deployment project or not; in the case that a project is not an incremental deployment project, adding a full deployment flag to the project; in the case where one project is an incremental deployment project, incremental deployment markers are added to the project. The incremental deployment mark is added to ensure that the incremental compiling or the full compiling of the item to be compiled is distinguished during the compiling.
Optionally, compiling, by the local compiling server, the items in the item list to be compiled to obtain the compiled product includes: respectively allocating a thread to each item in the item list to be compiled; before starting a thread corresponding to a current item to be compiled, judging whether the item to be compiled has a dependent item through a dependency relationship identifier; judging whether the dependent item is a parent item of the current item or not under the condition that the dependent item exists in the current item; stopping executing the thread of the current item and executing the thread corresponding to the parent item under the condition that the dependent item is the parent item; and compiling the current item to obtain a compiled product corresponding to the current item under the condition that the dependent item is not the parent item. By adjusting the compiling sequence of the compiling items with the dependency relationship, the items with the dependency relationship can be compiled according to the sequence, and compiling errors can not be caused.
Optionally, matching the compiled artifact to the preset deployment policy comprises: acquiring a compiled product and a preset deployment strategy; respectively checking whether the compiled product and the preset deployment strategy conform to preset rules; under the condition that the compiled product and the preset deployment strategy both accord with preset rules, executing a step of matching the compiled product with the preset deployment strategy; and under the condition that the compiled product and the preset deployment strategy do not accord with the preset rule, forbidding executing the step of matching the compiled product and the preset deployment strategy. And judging whether the processing result of the source code is successful or failed by matching the compiled product with a preset deployment strategy.
Optionally, in a case that the matching is successful, generating a deployment policy file of the compiled product includes: matching preset deployment strategies according to the operation and maintenance stages of the compiled product to obtain deployment strategies corresponding to the operation and maintenance stages; and generating a deployment strategy file according to the operation and maintenance phases of the compiled product and the deployment strategies corresponding to the operation and maintenance phases. The application of the system module corresponding to the operation and maintenance stage can be guided by generating the deployment strategy file.
According to another aspect of the present application, a system for processing source code is provided. The system comprises: the control unit is used for controlling the self-checking unit, the source code management unit, the project compiling unit and the deployment strategy management unit to work in sequence; the self-checking unit is used for executing pre-checking operation, wherein the pre-checking operation at least comprises configuration parameters of a checking system and external connection equipment of the checking system; the source code management unit is used for generating a source code management task, acquiring the identifier of a source code version library of each item in the source code management task and the branch information required by compiling each item, and downloading the source code of each item from a remote code hosting warehouse to a local compiling server according to the identifier and the branch information; the project compiling unit is used for determining a project compiling task according to the projects in the source code management task, generating a project list to be issued according to the source codes of all the projects in the project compiling task, preprocessing the projects to be compiled in the project list to be issued to obtain preprocessed projects, forming the project list to be compiled by the preprocessed projects, and compiling the projects in the project list to be compiled through the local compiling server to obtain a compiled product; and the deployment strategy management unit is used for matching the compiled product with a preset deployment strategy and generating a deployment strategy file of the compiled product under the condition of successful matching.
According to another aspect of the embodiments of the present invention, there is also provided a computer storage medium for storing a program, where the program controls a device in which the non-volatile storage medium is located to execute a processing method of source code when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including a processor and a memory; the memory stores computer readable instructions, and the processor is used for executing the computer readable instructions, wherein the computer readable instructions execute a processing method of source codes.
Through the application, the following steps are adopted: determining each project in the compiling task; acquiring the identification of a source code version library of each project, compiling branch information required by each project, and acquiring an interface of a distributed version control system; according to the identification and the branch information, acquiring the source code of each item from a remote code hosting warehouse through an interface, and storing the source code of each item to a local compiling server; generating a to-be-published item list according to the source code of each item, preprocessing items to be compiled in the to-be-published item list to obtain preprocessed items, and forming the to-be-compiled item list by the preprocessed items; compiling the items in the item list to be compiled through a local compiling server to obtain a compiled product; the compiled product is matched with a preset deployment strategy, and a deployment strategy file of the compiled product is generated under the condition of successful matching, so that the problem of low system project construction and deployment efficiency in the related technology is solved. The system project is processed uniformly by integrating the functions of source code management, project compiling and deployment strategy management, so that the effect of efficiently constructing and deploying the system project is achieved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the application and, together with the description, serve to explain the application and are not intended to limit the application. In the drawings:
FIG. 1 is a flow chart of a method for processing source code provided according to an embodiment of the present application;
FIG. 2 is a flowchart of a local compilation server downloading source code provided according to an embodiment of the present application;
FIG. 3 is a flowchart of a source code corresponding project deployment policy management provided according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a processing system structure of source code provided according to an embodiment of the present application;
FIG. 5 is a schematic diagram of an external connection environment of a source code processing system provided in accordance with an embodiment of the present application;
FIG. 6 is a flow diagram of a method of item compilation provided according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a device for processing source code provided according to an embodiment of the present application;
fig. 8 is a schematic diagram of an electronic device provided according to an embodiment of the present application.
Detailed Description
It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be used. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of description, some terms or expressions referred to in the embodiments of the present application are explained below:
and (6) Maven: apache Maven, generally called Maven for short, is a software (especially Java software) project management and automatic construction tool, and can manage the steps of construction, report, document and the like of a project by using a central information fragment based on the concept of an object model (POM).
Continuous integration: the method is a software engineering process, and is a measure for continuously integrating the working copies of the software of all software engineers into the shared main line mainline, and is used for solving various problems faced by the software in system integration.
Compiling: is a process for generating a target program from a written source code in a source language using a compiler, which can program a 2-ary language recognizable by a computer in a high-level language.
Sql: structured Query Language is a database Language having a plurality of functions such as data manipulation and data definition.
According to an embodiment of the application, a method for processing source codes is provided.
Fig. 1 is a flowchart of a method for processing source code according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
step S102, determining each item in the compiling task.
Specifically, each item in the compilation task refers to a system item to be updated with the source code.
Step S104, obtaining the identification of the source code version library of each project, compiling the branch information required by each project, and obtaining the interface of the distributed version control system.
Specifically, the source code version library is a remote code hosting warehouse for storing source codes of system projects, each project has a corresponding unique identifier in the source code version library, the branch information refers to information corresponding to the source codes to be modified and contained in the project, and the interface of the distributed version control system is an interface corresponding to a download path of the source code version library.
And S106, acquiring the source code of each item from the remote code hosting warehouse through the interface according to the identification and the branch information, and storing the source code of each item to the local compiling server.
Specifically, the identification and branch information can confirm the version library and the project branch where the source code needing to be updated is located, and the source code needing to be updated can be correspondingly downloaded to a local compiling server through the interface.
And S108, generating a to-be-published item list according to the source code of each item, preprocessing the items to be compiled in the to-be-published item list to obtain preprocessed items, and forming the to-be-compiled item list by the preprocessed items.
Specifically, the item list to be published is an item list which is corresponding to the system item and needs to be updated, the item list to be published includes items which need to be compiled and items which do not need to be compiled, the items which do not need to be compiled do not need to be preprocessed, the preprocessing is to add a dependency relationship mark and an increment updating mark to the items which need to be compiled before the items are compiled, and the items can be compiled correspondingly after the marks are added.
And step S110, compiling the items in the item list to be compiled through the local compiling server to obtain a compiled product.
Specifically, compiling the items in the item list to be compiled is to update the configuration of the source code to be updated, and obtain the updated source code, that is, the compiled product.
And step S112, matching the compiled product with a preset deployment strategy, and generating a deployment strategy file of the compiled product under the condition of successful matching.
Specifically, the preset deployment strategy is deployed according to the items corresponding to the modules involved in the operation and maintenance of the processing system of the source code, and the successful matching means that the items corresponding to the updated source code can be normally used in the operation and maintenance.
According to the source code processing method provided by the embodiment of the application, each project in a compiling task is determined; acquiring the identification of a source code version library of each project, compiling branch information required by each project, and acquiring an interface of a distributed version control system; according to the identification and the branch information, acquiring the source code of each item from a remote code hosting warehouse through an interface, and storing the source code of each item to a local compiling server; generating a to-be-published item list according to the source code of each item, preprocessing items to be compiled in the to-be-published item list to obtain preprocessed items, and forming the to-be-compiled item list by the preprocessed items; compiling the items in the item list to be compiled through a local compiling server to obtain a compiled product; the compiled product is matched with a preset deployment strategy, and a deployment strategy file of the compiled product is generated under the condition of successful matching, so that the problem of low system project construction and deployment efficiency in the related technology is solved. The system project is processed uniformly by integrating the functions of source code management, project compiling and deployment strategy management, so that the effect of efficiently constructing and deploying the system project is achieved.
Since the source code downloaded in the source code version library may not be adapted to the local compilation server, optionally, in the method for processing source code provided in the embodiment of the present application, after saving the source code of each item to the local compilation server, the method further includes: detecting whether the source code accords with a source code management rule; under the condition that the source code accords with the source code management rule, executing the step of generating a to-be-issued project list according to the source code of each project; and eliminating the source code under the condition that the source code does not accord with the source code management rule.
Specifically, the source code management rule is set for determining whether the downloaded code is adapted to the local compilation server, for example, the configuration code review rule, the code quality risk rule belong to the source code management rule, and if the downloaded code cannot be adapted to the local compilation server, the source code that can be adapted needs to be downloaded again. By detecting the source code, the corresponding system can be adapted after the source code is processed.
Optionally, in the method for processing source code provided in this embodiment of the present application, acquiring source code of each item from the remote code hosting repository through the interface according to the identifier and the branch information includes: judging whether a source code corresponding to the branch information of each project exists in the local compiling server; under the condition that the local compiling server does not have the source code corresponding to the branch information, all the source codes corresponding to the branch information are obtained from the remote code hosting warehouse; and acquiring the incremental source code corresponding to the branch information from the remote code hosting warehouse under the condition that the source code corresponding to the branch information exists in the local compiling server, wherein the incremental source code is different from the source code stored in the local compiling server.
Specifically, fig. 2 is a flowchart of downloading a source code by a local compilation server according to an embodiment of the present application, and as shown in fig. 2, the state of a source code repository in the local compilation server is determined, and it is checked whether a source code corresponding to each branch information of each item exists, for example, the branch information of one item includes branch information a and branch information B, and if the source code repository in the local compilation server does not have a source code corresponding to the branch information a, when downloading through a download path, the source code corresponding to the branch information a is fully downloaded (i.e., clone operation), that is, all source codes corresponding to the branch information a in a remote server are downloaded to the local compilation server; if the source code warehouse in the local compiling server has the source code corresponding to the B branch information, the source code corresponding to the B branch is incrementally downloaded (i.e. pull operation) when the source code warehouse is downloaded through the download path, that is, only the source code difference part between the remote server and the local compiling server is updated and merged. And judging the updating progress of the source code during downloading, and returning a status code of the updating progress to the processing system of the source code. The source code is obtained through the incremental downloading mode and the full downloading mode, so that the local compiling server can be efficiently utilized, and bandwidth resources required by downloading the source code are not wasted.
Optionally, in the method for processing source code provided in this embodiment of the present application, before preprocessing an item to be compiled in an item list to be published, the method further includes: judging whether an item in an item list to be issued is associated with preset mark information, wherein the preset mark information is used for indicating that the item needs to be compiled; and classifying items in the item list to be issued according to whether the preset mark information is associated or not to obtain items needing to be compiled and items not needing to be compiled, wherein the items needing to be compiled are the items associated with the preset mark information, and the items not needing to be compiled are the items not associated with the preset mark information.
Specifically, the preset flag information is a flag bit corresponding to an object model configuration file (i.e., pom. xml), the obtained list of items to be published is analyzed line by line, and the items in the list are divided into two categories according to whether compiling is required, the method for judgment is that the items in the list and corresponding parent directories and same-level directories are recursively scanned, whether the necessary item object model configuration file of Maven is included is taken as the flag bit required to be compiled, an item branch which does not need to be compiled does not have the flag bit of the object model configuration file, and an item branch which needs to be compiled has the flag bit of the object model configuration file. For branches that do not require compilation: such as configuration files, database sql scripts related to configuration, etc., such branches are transferred directly to the compiled artifact; for branches requiring compilation, which are usually files contained in java projects, the branches need to be compiled by a compiler before being run on a server, and such branches are compiled by a local compiling server. By distinguishing whether the items need to be compiled or not, the local compiling server can not repeatedly compile to cause resource waste during compiling.
Optionally, in the method for processing a source code provided in this embodiment of the present application, the preprocessing the item to be compiled in the item list to be published includes: judging whether a dependency relationship exists between each item in the item list to be compiled and other items, wherein the other items are the items in the compiled item list; determining the item information of the item and marking a dependency relationship identifier under the condition that a dependency relationship does not exist between one item and other items; when the dependency relationship exists between one item and other items, determining the dependency item corresponding to the item, determining the information of the item and marking the dependency relationship identifier, and determining the item information of the dependency item and marking the dependency relationship identifier.
Specifically, the branches to be compiled in the list to be published are processed one by one, the branches to be compiled comprise object model configuration files, and whether dependency exists between different branches in the list to be published is judged by analyzing the item object model configuration files. The dependency relationship is determined by checking whether the configurations of the different branches affect each other, for example, if there is a dependency relationship between the branch a and the branch B, then after updating the parameter corresponding to the branch a, the parameter corresponding to the branch B needs to be adjusted. If the dependency relationship does not exist between the branches to be issued, collecting information of the items to be compiled in the list to be issued and marking the compiling elements, wherein the compiling elements comprise item object model configuration, increment updating marks, dependency relationship analysis and the like; if the dependency relationship exists between branches to be issued, analyzing the project object model configuration file of the Maven project where A, B is located according to the obtained A, B branch with the dependency relationship, determining the parent-child dependency relationship of the A, B branch, namely determining that updating the parameters of the A branch can influence the B branch, the A branch is a parent project branch, and adding a parent project dependency identifier to the B branch, or updating the parameters of the B branch can influence the A branch, the B branch is a parent project branch, and the A branch is added with a parent project dependency identifier. By confirming the dependency relationship among the items, compiling errors caused by disordered compiling sequences of the items with the dependency relationship during compiling are avoided.
Optionally, in the method for processing source code provided in this embodiment of the present application, the preprocessing the item to be compiled in the item list to be published further includes: judging whether each project in the project list to be compiled is an incremental deployment project or not; in the case that a project is not an incremental deployment project, adding a full deployment flag to the project; in the case where one project is an incremental deployment project, incremental deployment markers are added to the project.
Specifically, whether the incoming branches to be issued are incremental deployment items is judged one by one according to the list of the items to be issued. The incremental deployment project only modifies the business logic, so the change amount of the project is usually small, the actual compiling and deployment can take effect only by updating the part needing to be modified, the incremental updating promotes the development and the test with the rhythm of 'small-step fast running', and the efficiency of version iterative compiling and deployment can be effectively improved. Judging the incremental deployment project according to whether a change list corresponding to the branch to be issued only contains Java project source code files, for example, the C project is the incremental deployment project, which indicates that the C project only has service logic modification in the compiling task at this time, and is an incremental deployment project without a newly added dependency package, and performing incremental compiling on the C project; for example, the D item is not an incremental deployment item, and a change list corresponding to the D item includes an item object model configuration file, a configuration file, and the like, which indicates that a dependency package or a configuration variable may be added to the D item in the current compiling task, and the D item needs to be completely compiled. Adding a full deployment mark to a project needing full deployment, further analyzing an object model configuration file for an incremental deployment project, identifying a target jar file of the project to be compiled, performing the incremental deployment mark on the incremental deployment project, completing the analysis of a project list to be compiled, generating a project list to be compiled containing a compilation element mark, and performing parallel compilation on the projects in the project list to be compiled. The incremental deployment mark is added to ensure that the incremental compiling or the full compiling of the item to be compiled is distinguished during the compiling.
Optionally, in the method for processing source code provided in the embodiment of the present application, compiling, by a local compiling server, an item in a to-be-compiled item list to obtain a compiled product includes: respectively allocating a thread to each item in the item list to be compiled; before starting a thread corresponding to a current item to be compiled, judging whether the item to be compiled has a dependent item through a dependency relationship identifier; judging whether the dependent item is a parent item of the current item or not under the condition that the dependent item exists in the current item; stopping executing the thread of the current item and executing the thread corresponding to the parent item under the condition that the dependent item is the parent item; and compiling the current item to obtain a compiled product corresponding to the current item under the condition that the dependent item is not the parent item.
Specifically, before parallel compilation starts, whether a parent item dependency exists in an item of the thread is judged, for example, if the parent item dependency exists in an item E, namely the item E carries a parent item dependency identifier, priority adjustment is performed on the thread, the item E enters a dormant state and a blocking state, and compilation is restarted on the item E after compilation of a dependent item of the item E is completed; for example, the F item has no parent item dependency identification and directly calls a compiling method for compiling. And for the item with the compiling failure, the thread allows the failed item to retry the compiling for three times, and for the item with the compiling success frequency larger than 1, the state information of the compiling completion is sent to the processing system of the source code. And (3) classifying and classifying file object lists in the compiled products according to preset rules, such as whether the compiled products are binary files, whether the compiled products are configuration files, whether the compiled products are tightly coupled with environment information and other elements, compressing the compiled products according to configuration parameters and a certain naming rule, and sending a compiling task completion signal to a source code processing system. By adjusting the compiling sequence of the compiling items with the dependency relationship, the items with the dependency relationship can be compiled according to the sequence, and compiling errors can not be caused.
Optionally, in the method for processing a source code provided in the embodiment of the present application, matching the compiled product with a preset deployment policy includes: acquiring a compiled product and a preset deployment strategy; respectively checking whether the compiled product and the preset deployment strategy conform to preset rules; under the condition that the compiled product and the preset deployment strategy both accord with preset rules, executing a step of matching the compiled product with the preset deployment strategy; and under the condition that the compiled product and the preset deployment strategy do not accord with the preset rule, forbidding executing the step of matching the compiled product and the preset deployment strategy.
Specifically, the deployment policy is a rule for distributing the compiled product to the operation and maintenance system, and the deployment policy includes a rule trigger condition, distributed server information, an operating system user for executing distribution, a right of a distributed medium, a self-customized executing operating system script and the like. Fig. 3 is a flowchart of management of a deployment policy of a project corresponding to a source code according to an embodiment of the present application, where as shown in fig. 3, a processing system of the source code invokes a new deployment policy management task, submits information of a compiled product and a preset deployment policy configuration as entry parameters to a deployment policy management unit, the deployment policy management unit performs legal verification on received parameters and a local configuration file, then loads a preset deployment policy, matches an obtained preset deployment policy with the compiled product, and if the compiled product does not conform to the preset deployment policy configuration, that is, the compiled product cannot complete a task assigned by the preset deployment policy, then construction of the system project cannot be completed, and an error signal is sent to a processing system of the source code; if the configuration of the compiled product and the preset deployment strategy can be matched, that is, the compiled product can complete the task of the preset deployment strategy allocation, which indicates that the construction of the system project is completed. And judging whether the processing result of the source code is successful or failed by matching the compiled product with a preset deployment strategy.
Optionally, in the method for processing a source code provided in the embodiment of the present application, generating a deployment policy file of a compiled product includes, when matching is successful, that the system project enters an operation and maintenance stage after the system project is constructed: matching preset deployment strategies according to the operation and maintenance stages of the compiled product to obtain deployment strategies corresponding to the operation and maintenance stages; and generating a deployment strategy file according to the operation and maintenance phases of the compiled product and the deployment strategies corresponding to the operation and maintenance phases.
Specifically, as shown in fig. 3, the deployment policy of each system function module is read from the configuration file of the local compilation server, and is closely related to the operation steps of the operation and maintenance phase of the system. The deployment strategy of each module consists of a plurality of program deployment elements, and can be divided into five modules of directory preprocessing, updating medium transmission, configuration file transmission, function starting and custom script operation according to the priority sequencing according to the classification of operation and maintenance stage operation steps of system project construction and deployment tools. And generating a formatted automatic deployment strategy file for the operation and maintenance stage according to the analysis result of the compiled products and the deployment strategy, wherein the formatted automatic deployment strategy file corresponds to the compiled products generated by the construction task one by one and can be used for system project construction and deployment tool automatic operation and maintenance. The application of the system module corresponding to the operation and maintenance stage can be guided by generating the deployment strategy file.
According to another embodiment of the present application, a system for processing source code is provided. Fig. 4 is a schematic structural diagram of a system for processing source code provided according to an embodiment of the present application, and as shown in fig. 4, the system includes: a control unit 401, configured to control the self-test unit 402, the source code management unit 403, the project compiling unit 404, and the deployment policy management unit to sequentially work 405; a self-checking unit 402, configured to perform a pre-checking operation, where the pre-checking operation at least includes configuration parameters of a checking system and an external connection device of the checking system; a source code management unit 403, configured to generate a source code management task, obtain an identifier of a source code version library of each item in the source code management task and branch information required for compiling each item, and download the source code of each item from a remote code hosting repository to a local compilation server according to the identifier and the branch information; the project compiling unit 404 is configured to determine a project compiling task according to the projects in the source code management task, generate a to-be-published project list according to the source codes of the various projects in the project compiling task, preprocess the projects to be compiled in the to-be-published project list to obtain preprocessed projects, form the to-be-compiled project list by the preprocessed projects, and compile the projects in the to-be-compiled project list through the local compiling server to obtain a compiled product; the deployment policy management unit 405 is configured to match the compiled product with a preset deployment policy, and generate a deployment policy file of the compiled product if the matching is successful.
Specifically, the present invention provides a source code processing system, which includes: the control unit 401 is configured to provide functions such as overall flow control and retry of a failed task, and the self-checking unit 402, the source code management unit 403, the project compiling unit 404, and the deployment policy management unit 405, which are connected to the control unit 401, form four main parts of the system. The self-checking unit 402 is composed of a parameter analyzing module 21 and an environment checking module 22, and performs validity check on input parameters, loads necessary configuration parameters, and performs pre-check on environment availability, and if a pre-check process passes and all configuration parameters are loaded, sends a signal to the control unit 401 to indicate that the system has entered an operating state.
The source code management unit 403 is composed of a version control system docking module 31 and a code library management module 32, and provides a local source code repository and a source code version control function for a source code processing system, so as to ensure that a software system corresponding to a source code is released as a complete whole after being developed with different characteristics and continuously integrated. The version control system docking module 31 may be integrated with sophisticated distributed version control tools including Git, Gitlab, etc. The code library management module 32 may provide customized source code management rules, such as configuration code review rules, code quality risk rules, etc., for the software system under development based on project requirements.
The item compiling unit 404 is composed of an incremental program list identification module 41, a Java item constructing, configuring and analyzing module 42, and a compiling output object classification module 43, and is an important component of a source code processing system, the incremental program list identification module 41 and the Java item constructing, configuring and analyzing module 42 are used for preprocessing items to be compiled in an item list to be issued, and the compiling output object classification module 43 is used for compiling items in the item list to be compiled to obtain a compiled product.
The deployment policy management unit 405 is composed of a deployment rule parsing module 51 and a deployment policy generating module 52, is a management unit for program-oriented deployment automation, and provides a configuration management tool chain for automated deployment for a system project corresponding to a source code. By carrying out configuration management on basic equipment deployed by software as codes, the system in a development state and a running state shares a homogeneous basic environment, so that the production problem caused by the difference of the environments is reduced.
IT should be noted that fig. 5 is a schematic diagram of an external connection environment of a source code processing system according to an embodiment of the present application, and as shown in fig. 5, a system project building and deployment system is composed of a distributed version control system 501, a persistent integration system 502, and a system project building and deployment workflow system 503, where each update of a complex IT system requires a developer to initiate a change from the distributed version control system 501, and the complex IT system is connected to the system project building and deployment workflow system 503 through the persistent integration system 502, and can complete release after a complete three-phase system project building and deployment workflow. The distributed version control system 501 is a code repository of a project, and comprises a plurality of code version libraries which are divided into a code library for storing parameters or configuration tables and a code library 1-a code library n for storing system characteristic functions according to function differentiation; the system project construction and deployment workflow system 503 can be divided into three stages, namely a source code processing system, a deployment strategy system and an operation and maintenance system.
According to another embodiment provided herein, a method of project compilation is provided.
Fig. 6 is a flowchart of a method for compiling a project according to an embodiment of the present application, and as shown in fig. 6, the main control program invokes a new project compiling task and transmits all necessary parameters and configuration files, such as source code version library branch information, source code warehouse storage directory, list of projects to be released, compiled product directory, and the like, to the compiling process. And loading and analyzing the parameters and the local configuration file transmitted by the main control program, linking a distributed version control product of the source code management unit after the analysis of the entry parameters and the local configuration file is completed, and acquiring the program to be released or the configuration list related to the compiling task in combination with the version control label information in the entry parameters. The obtained item list to be issued is analyzed line by line, the items in the list are divided into two categories according to whether compiling is needed, the items and the father directory and the same-level directory of the items are registered in a recursive scanning mode, and whether a necessary item object model configuration file (namely pom. xml) of Maven is contained or not is used as a flag bit needing compiling. For entries that do not require compilation: such as configuration files, configuration-related database sql scripts, etc., which are directly submitted to a compiler pulling module without a compilation branch, and the configuration work directory is classified into an incoming document object list according to predetermined rules, such as whether the configuration work directory is a binary file, whether the configuration work directory is a configuration file, whether the configuration work directory is tightly coupled with environment information, etc. Analyzing the transmitted catalog where the compiled product is located, compressing the compiled product according to configuration parameters and a certain naming rule, and sending a compiling task completion signal to the control unit.
For items to be compiled, usually files contained in java items, which need to be compiled by a compiler, the items can be run on a server only after the compilation is completed, the items are processed by a compiling branch, a list object composed of compiling elements such as item object model configuration (pom. xml), increment updating marks, dependency analysis and the like is output by analyzing the list to be issued item one by one, and the specific steps are as follows: processing items needing to be compiled in the list to be released one by one, analyzing a project object model configuration file (pom. xml), and judging whether a dependency relationship exists among a plurality of items in the list to be released. And if the dependency relationship does not exist among the items to be published, collecting information of the items to be compiled in the list to be published, marking the compiling elements, and submitting the information objects of the items to be compiled to the identification compiling target jar in the form of object addition, wherein the compiling elements comprise item object model configuration (namely pom. Since the list of items to be published may not contain the compilation parent item, the final number of items to be compiled is greater than or equal to the number of items to be published.
If the dependency relationship exists among the items to be issued, analyzing the item object model configuration file (pom. xml) of the Maven item where the items to be issued exist according to the acquired items to be issued with the dependency relationship, determining the parent-child dependency relationship of the items to be issued, and sending the parent-child item object information to the compiling element marking module in an asynchronous mode. And judging whether the introduced items to be published are incremental deployment items or not according to the acquired list to be published. Whether incremental deployment is needed or not is used as a judgment basis, because the change amount of the project only modifying the business logic is usually small, the actual compiling and deployment can take effect only by updating the changed part, the incremental updating promotes the development and the test with the rhythm of 'small-step fast running', and the efficiency of version iterative compiling and deployment can be effectively improved. The incremental deployment decision is based on: if the change list of the items to be published only contains Java item source code files, the change list only contains modification of business logic in the compiling task, no newly added dependency package exists, the items are incremental deployment items, object model configuration files (pom.xml) are further analyzed, target jar files of the compiling items are identified, inventory increase deployment attribute marks are carried out on the items to be compiled, and object attribute asynchronous updating requests are sent to a pre-compiled pom.xml list; if the change list of the items to be published contains a project object model configuration file (pom. xml), a configuration file (application properties), and the like, it indicates that the compiling task may add a dependency package or a configuration variable, and the project needs to be completely compiled. Acquiring a project needing full deployment, adding a full deployment mark, and initiating an object attribute asynchronous updating request to a pre-compiled pom.
And completing the analysis of the list of the items to be compiled, generating the analysis of the list of the items to be compiled including the compiling element marks, and submitting the list to a compiling module for parallel compiling. And receiving an incoming list of items to be compiled, finishing the initialization of a thread pool, distributing a thread for each task to be compiled, and entering parallel compilation. Before parallel compiling is started, whether the item of the thread has parent item dependence is judged, if the parent item dependence exists, the thread sends a priority adjusting request to a scheduling module in the parallel compiling flow, and the scheduling module is responsible for updating the state of the item list to be compiled and determining the life cycle of each distributed thread holding a compiling task, specifically, the thread priority adjusting request including a compiling completion condition is processed to enter a dormant state or a blocked state. After the list of all items to be compiled is processed, initiating a request for compiling the product transfer, and then entering a dormant state and a blocking state; if the parent project is not dependent, the thread enters a compiling completion condition counting module of the thread, and the project which fails to be compiled is allowed to retry for three times and is resubmitted to the thread; for the items with the compiling success times larger than 1, sending a completion condition updating request to a scheduling module in the parallel compiling flow; and submitting the catalog information of the compiled product to a subsequent module, analyzing the imported catalog of the compiled product, compressing the compiled product according to configuration parameters and a certain naming rule, and sending a compiling task completion signal to the control unit.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
The embodiment of the present application further provides a source code processing apparatus, and it should be noted that the source code processing apparatus in the embodiment of the present application may be used to execute the processing method for the source code provided in the embodiment of the present application. The following describes a processing apparatus for source code provided in an embodiment of the present application.
Fig. 7 is a schematic diagram of a source code processing apparatus according to an embodiment of the present application. As shown in fig. 7, the apparatus includes: a determination unit 10 for determining each item in the compilation task; an obtaining unit 20, configured to obtain an identifier of a source code version library of each item, branch information required for compiling each item, and obtain an interface of the distributed version control system; the storage unit 30 is configured to obtain a source code of each item from the remote code hosting repository through the interface according to the identifier and the branch information, and store the source code of each item to the local compiling server; the generating unit 40 is configured to generate a to-be-published item list according to the source code of each item, pre-process items to be compiled in the to-be-published item list to obtain pre-processed items, and form the to-be-compiled item list from the pre-processed items; the compiling unit 50 is used for compiling the items in the item list to be compiled through the local compiling server to obtain a compiled product; the matching unit 60 is configured to match the compiled product with a preset deployment policy, and generate a deployment policy file of the compiled product if the matching is successful.
The processing apparatus of source code provided by the embodiment of the present application, through the determining unit 10, is configured to determine each item in the compiling task; an obtaining unit 20, configured to obtain an identifier of a source code version library of each item, branch information required for compiling each item, and obtain an interface of the distributed version control system; the storage unit 30 is configured to obtain a source code of each item from the remote code hosting repository through the interface according to the identifier and the branch information, and store the source code of each item to the local compiling server; the generating unit 40 is configured to generate a to-be-published item list according to the source code of each item, pre-process items to be compiled in the to-be-published item list to obtain pre-processed items, and form the to-be-compiled item list from the pre-processed items; the compiling unit 50 is used for compiling the items in the item list to be compiled through the local compiling server to obtain a compiled product; the matching unit 60 is configured to match the compiled product with a preset deployment policy, and generate a deployment policy file of the compiled product when the matching is successful, so that the problem of low system project construction and deployment efficiency in the related art is solved, and the system project is processed uniformly by integrating functions of source code management, project compilation and deployment policy management, so that the effect of efficient construction and deployment of the system project is achieved.
Optionally, in the apparatus for processing source code provided in the embodiment of the present application, the apparatus further includes: the detection unit is used for detecting whether the source code accords with a source code management rule; under the condition that the source code accords with the source code management rule, executing the step of generating a to-be-issued project list according to the source code of each project; and eliminating the source code under the condition that the source code does not accord with the source code management rule.
Optionally, in the apparatus for processing source code provided in the embodiment of the present application, the storage unit 30 includes: the first judgment module is used for judging whether a source code corresponding to the branch information of each project exists in the local compiling server or not; the first obtaining module is used for obtaining all source codes corresponding to the branch information from the remote code hosting warehouse under the condition that the source codes corresponding to the branch information do not exist in the local compiling server; and the second obtaining module is used for obtaining the incremental source code corresponding to the branch information from the remote code hosting warehouse under the condition that the source code corresponding to the branch information exists in the local compiling server, wherein the incremental source code is different from the source code stored in the local compiling server.
Optionally, in the apparatus for processing source code provided in the embodiment of the present application, the generating unit 40 includes: the second judgment module is used for judging whether an item in the item list to be issued is associated with preset mark information, wherein the preset mark information is used for indicating that the item needs to be compiled; the classification module is used for classifying the items in the item list to be issued according to whether the preset mark information is associated or not, so as to obtain the items needing to be compiled and the items not needing to be compiled, wherein the items needing to be compiled are the items associated with the preset mark information, and the items not needing to be compiled are the items not associated with the preset mark information.
Optionally, in the apparatus for processing source code provided in the embodiment of the present application, the generating unit 40 further includes: the third judging module is used for judging whether a dependency relationship exists between each item in the item list to be compiled and other items, wherein the other items are the items in the compiled item list; the first determining module is used for determining the item information of the item and marking a dependency relationship identifier under the condition that the dependency relationship does not exist between one item and other items; and the second determining module is used for determining the dependent item corresponding to the item, determining the information of the item and marking the dependency identification, and determining the item information of the dependent item and marking the dependency identification under the condition that the dependency exists between one item and other items.
Optionally, in the apparatus for processing source code provided in the embodiment of the present application, the generating unit 40 further includes: the fourth judging module is used for judging whether each item in the item list to be compiled is an incremental deployment item; the system comprises a first marking module, a second marking module and a third marking module, wherein the first marking module is used for adding a full deployment mark to a project under the condition that the project is not an incremental deployment project; and the second marking module is used for adding the incremental deployment mark to the project under the condition that one project is the incremental deployment project.
Optionally, in the processing apparatus of source code provided in this embodiment of the present application, the compiling unit 50 includes: the distribution module is used for respectively distributing a thread for each item in the item list to be compiled; the fifth judging module is used for judging whether the item to be compiled has a dependent item or not through the dependency relationship identifier before starting the thread corresponding to the current item to be compiled; the fifth judging module comprises a judging submodule for judging whether the dependent item is a parent item of the current item under the condition that the dependent item exists in the current item; the first execution module is used for stopping executing the thread of the current item and executing the thread corresponding to the parent item under the condition that the dependent item is the parent item; and the compiling module is used for compiling the current item to obtain a compiled product corresponding to the current item under the condition that the dependent item is not the parent item.
Optionally, in the apparatus for processing source code provided in the embodiment of the present application, the matching unit 60 includes: the third acquisition module is used for acquiring compiled products and a preset deployment strategy; the verification module is used for respectively verifying whether the compiled product and the preset deployment strategy conform to preset rules; the second execution module is used for executing the step of matching the compiled product with the preset deployment strategy under the condition that the compiled product and the preset deployment strategy both accord with the preset rule; and the prohibiting module is used for prohibiting executing the step of matching the compiled product with the preset deployment strategy under the condition that the compiled product and the preset deployment strategy do not accord with the preset rule.
Optionally, in the apparatus for processing source code provided in this embodiment of the present application, the matching unit 60 further includes: the matching module is used for matching the preset deployment strategies according to the operation and maintenance stages of the compiled product to obtain the deployment strategies corresponding to the operation and maintenance stages; and the generation module is used for generating a deployment strategy file according to the operation and maintenance phases of the compiled product and the deployment strategies corresponding to the operation and maintenance phases.
The source code processing device includes a processor and a memory, the determining unit 10, the obtaining unit 20, the storing unit 30, the generating unit 40, the compiling unit 50, the matching unit 60, and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. One or more than one kernel can be set, and the effect of automatic and efficient construction and deployment of the system project is achieved by adjusting kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The embodiment of the application also provides a computer storage medium, wherein the computer storage medium is used for storing the program, and the program controls the equipment where the nonvolatile storage medium is located to execute the processing method of the source code when running.
Fig. 8 is a schematic diagram of an electronic device provided in an embodiment of the present application, and as shown in fig. 8, an electronic device 801 includes a processor and a memory; the memory stores computer readable instructions, and the processor is used for executing the computer readable instructions, wherein the computer readable instructions execute a processing method of source codes. The electronic device herein may be a server, a PC, a PAD, a mobile phone, etc.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art to which the present application pertains. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (12)

1. A method for processing source code, comprising:
determining each project in the compiling task;
acquiring the identification of the source code version library of each project, compiling the branch information required by each project and acquiring an interface of a distributed version control system;
according to the identification and the branch information, acquiring the source code of each item from a remote code hosting warehouse through the interface, and storing the source code of each item to a local compiling server;
generating a to-be-published item list according to the source codes of the items, preprocessing items to be compiled in the to-be-published item list to obtain preprocessed items, and forming the to-be-compiled item list by the preprocessed items;
compiling the items in the item list to be compiled through the local compiling server to obtain a compiled product;
and matching the compiled product with a preset deployment strategy, and generating a deployment strategy file of the compiled product under the condition of successful matching.
2. The method of claim 1, wherein after saving the source code of the respective item to the local compilation server, the method further comprises:
detecting whether the source code accords with a source code management rule;
under the condition that the source code accords with a source code management rule, executing a step of generating a to-be-issued project list according to the source code of each project;
and eliminating the source code under the condition that the source code does not accord with the source code management rule.
3. The method of claim 1, wherein obtaining source code for the respective item from a remote code hosting repository through the interface based on the identification and the branching information comprises:
judging whether a source code corresponding to the branch information of each project exists in the local compiling server or not;
under the condition that the local compiling server does not have the source code corresponding to the branch information, all source codes corresponding to the branch information are obtained from the remote code hosting warehouse;
and when the source code corresponding to the branch information exists in the local compiling server, acquiring the incremental source code corresponding to the branch information from the remote code hosting warehouse, wherein the incremental source code is different from the source code stored in the local compiling server.
4. The method of claim 1, wherein before preprocessing the item to be compiled in the to-be-published item list, the method further comprises:
judging whether an item in the item list to be issued is associated with preset mark information, wherein the preset mark information is used for indicating that the item needs to be compiled;
classifying the items in the item list to be issued according to whether the preset mark information is associated, so as to obtain the items to be compiled and the items not to be compiled, wherein the items to be compiled are the items associated with the preset mark information, and the items not to be compiled are the items not associated with the preset mark information.
5. The method of claim 1, wherein preprocessing items to be compiled in the to-be-published item list comprises:
judging whether a dependency relationship exists between each item in the item list to be compiled and other items, wherein the other items are the items in the compiled item list;
under the condition that the dependency relationship does not exist between one item and other items, determining item information of the item and marking a dependency relationship identifier;
and under the condition that the dependency relationship exists between one item and other items, determining a dependency item corresponding to the item, determining the information of the item and marking a dependency relationship identifier, and determining the item information of the dependency item and marking a dependency relationship identifier.
6. The method of claim 1, wherein preprocessing the item to be compiled in the to-be-published item list further comprises:
judging whether each project in the project list to be compiled is an incremental deployment project or not;
in the event that a project is not the incremental deployment project, adding a full deployment flag to the project;
in the event that a project is the incremental deployment project, an incremental deployment flag is added to the project.
7. The method of claim 5, wherein compiling, by the local compilation server, the items in the list of items to be compiled to obtain a compiled product comprises:
respectively allocating a thread to each item in the item list to be compiled;
before starting a thread corresponding to a current item to be compiled, judging whether a dependent item exists in the item to be compiled or not through the dependency relationship identifier;
judging whether the dependent item is a parent item of the current item or not under the condition that the dependent item exists in the current item;
stopping executing the thread of the current item and executing the thread corresponding to the parent item under the condition that the dependent item is the parent item;
and compiling the current item to obtain a compiled product corresponding to the current item under the condition that the dependent item is not the parent item.
8. The method of claim 1, wherein matching the compiled artifact to a pre-set deployment policy comprises:
acquiring the compiled product and the preset deployment strategy;
respectively checking whether the compiled product and the preset deployment strategy meet preset rules;
under the condition that the compiled product and the preset deployment strategy both accord with the preset rule, executing a step of matching the compiled product with the preset deployment strategy;
and under the condition that the compiled product and the preset deployment strategy do not accord with the preset rule, prohibiting executing the step of matching the compiled product with the preset deployment strategy.
9. The method of claim 1, wherein in the event of a successful match, generating a deployment policy file for the compiled artifact comprises:
matching the preset deployment strategies according to the operation and maintenance stages of the compiled product to obtain deployment strategies corresponding to the operation and maintenance stages;
and generating the deployment strategy file according to the operation and maintenance phases of the compiled product and the deployment strategies corresponding to the operation and maintenance phases.
10. A system for processing source code, comprising:
the control unit is used for controlling the self-checking unit, the source code management unit, the project compiling unit and the deployment strategy management unit to work in sequence;
the self-checking unit is used for executing pre-checking operation, wherein the pre-checking operation at least comprises checking configuration parameters of a system and checking external connection equipment of the system;
the source code management unit is used for generating a source code management task, acquiring an identifier of a source code version library of each item in the source code management task and branch information required for compiling each item, and downloading a source code of each item from a remote code hosting warehouse to a local compiling server according to the identifier and the branch information;
the project compiling unit is used for determining a project compiling task according to the projects in the source code management task, generating a project list to be issued according to the source codes of all the projects in the project compiling task, preprocessing the projects needing to be compiled in the project list to be issued to obtain preprocessed projects, forming the project list to be compiled by the preprocessed projects, and compiling the projects in the project list to be compiled through the local compiling server to obtain a compiled product;
and the deployment strategy management unit is used for matching the compiled product with a preset deployment strategy and generating a deployment strategy file of the compiled product under the condition of successful matching.
11. A computer storage medium for storing a program, wherein the program when executed controls an apparatus in which the computer storage medium is located to execute the method for processing source code according to any one of claims 1 to 9.
12. An electronic device comprising a processor and a memory, the memory having stored therein computer-readable instructions, the processor being configured to execute the computer-readable instructions, wherein the computer-readable instructions are configured to execute the method for processing source code according to any one of claims 1 to 9.
CN202210135551.3A 2022-02-14 2022-02-14 Source code processing method, system, storage medium and electronic equipment Pending CN114489676A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210135551.3A CN114489676A (en) 2022-02-14 2022-02-14 Source code processing method, system, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210135551.3A CN114489676A (en) 2022-02-14 2022-02-14 Source code processing method, system, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN114489676A true CN114489676A (en) 2022-05-13

Family

ID=81481130

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210135551.3A Pending CN114489676A (en) 2022-02-14 2022-02-14 Source code processing method, system, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114489676A (en)

Similar Documents

Publication Publication Date Title
CN111399853B (en) Templated deployment method for machine learning model and custom operator
CA3096768A1 (en) System and method for automated microservice source code generation and deployment
CN108845940B (en) Enterprise-level information system automatic function testing method and system
CN111158674B (en) Component management method, system, device and storage medium
CN110597531B (en) Distributed module upgrading method and device and storage medium
CN104077140A (en) Automatic compiling method and compiling device for continuous integration
CN111142879A (en) Software integration release method and automatic operation and maintenance platform
US10514898B2 (en) Method and system to develop, deploy, test, and manage platform-independent software
US9904574B2 (en) Parallel computing without requiring antecedent code deployment
CN111124871A (en) Interface test method and device
CN111045751A (en) Multi-service configuration chain processing method and device
CN101753619B (en) Method and system for extending service model
CN114637511A (en) Code testing system, method, device, electronic equipment and readable storage medium
CN116132139A (en) Scenario execution method, scenario execution device, scenario execution equipment, scenario execution storage medium and scenario execution program product
CN103186463A (en) Method and system for determining testing range of software
CN115220863A (en) Operation and maintenance method and device for container application, computer equipment and storage medium
US20100122258A1 (en) Versioning and effectivity dates for orchestration business process design
CN112631763A (en) Program changing method and device of host program
US20200356885A1 (en) Service management in a dbms
US9396239B2 (en) Compiling method, storage medium and compiling apparatus
CN116400950A (en) DevOps element pipeline system based on version control
CN114489676A (en) Source code processing method, system, storage medium and electronic equipment
US10958514B2 (en) Generating application-server provisioning configurations
CN113721906A (en) Common module extraction method, device, equipment and medium for service merging
CN113126998A (en) Incremental source code acquisition method and device, electronic equipment and storage medium

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