Code management method and device and storage medium
By dynamically creating and managing proxy nodes in a continuous integration system, using multiple containers to perform different steps, and implementing message feedback through message plug-ins, the problem of untimely message feedback for continuous integration execution and limited scalability of Jenkins resource management is solved, and the system's scalability and timeliness of message feedback are improved.
Patent Information
- Application Number
- CN202411782628.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-28
AI Technical Summary
The problem of untimely feedback on continuous integration execution in the prior art and the limited scalability of Jenkins in resource management and task execution.
By obtaining the operations of target users in real time on the target code hosting platform, dynamically creating and managing proxy nodes, using multiple containers to perform different steps to improve the scalability of resource management and task execution, and sending the execution results to the message display platform through the message plug-in to achieve timely message feedback.
It improves the scalability of the continuous integration system in resource management and task execution, and realizes the timely message feedback of code integration construction, solving the problem of untimely message feedback of continuous integration execution in the existing technology and limited scalability of Jenkins in resource management and task execution.
Smart Images

Figure CN119718644A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular to a code management method, device and storage medium. Background Art
[0002] In modern software development, with the increasing frequency of code updates and the growth of complexity, software testing has become a key link in ensuring product quality and reliability. In order to ensure the quality and reliability of software products, development team members need to continuously test the code and identify and fix potential errors as quickly as possible. However, the manual testing process is not only time-consuming but also prone to errors. Therefore, an automated solution is urgently needed to detect and solve problems.
[0003] Jenkins (Jenkins Automation Server) is a widely used open source continuous integration tool developed based on Java (Java Programming Language). It provides an intuitive web interface and a rich plug-in ecosystem, and can automate various build and test tasks. Its core functions include source code management, build triggering, automated testing, deployment and other advanced features. Through Jenkins, developers can easily implement the CI process (Continuous Integration Process), thereby improving the efficiency of software development and maintenance.
[0004] However, when combining Bitbucket (Bitbucket Code Repository, Bitbucket code hosting service) with Jenkins for software development, although the existing general solutions realize basic interactive functions, in actual operation, there may be problems that do not match the actual work requirements. Specifically, these problems are mainly manifested in:
[0005] (1) Untimely feedback: During the continuous integration process, existing solutions often fail to provide timely feedback, resulting in team members being unable to quickly understand the status of the build and test.
[0006] (2) Difficulty in expanding resources and tasks: As the scale of the project expands, the existing solution faces the problem of insufficient scalability in terms of Jenkins server resources and job operations, which affects the team's work efficiency and the speed of software delivery.
[0007] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0008] The present application provides a code management method, device and storage medium to at least solve the technical problems in the prior art of untimely message feedback for continuous integration execution and limited scalability of Jenkins in resource management and task execution.
[0009] According to one aspect of the present application, a code management method is provided, including: determining a target operation performed by a target user on a code according to a target code hosting platform, wherein the target code hosting platform is a platform for managing code; creating a corresponding proxy node on a target system according to the target operation, wherein the proxy node is used to execute tasks assigned by a master node of a target automation tool, the proxy node includes multiple containers, and different containers execute different steps, wherein the target system is used to automatically deploy, manage and coordinate proxy nodes and master nodes, and the target automation tool is used to implement code integration and code deployment in software development; executing a code build operation according to the proxy node to obtain an execution result, wherein the code build operation is used to compile, run tests, and package and deploy the code; and sending the execution result to a message display platform through a message plug-in.
[0010] Optionally, creating a corresponding proxy node on the target system according to the target operation includes: generating event information according to the target operation, wherein the event information refers to data related to the target operation; obtaining permission information in the event information, wherein the permission information is used to identify the task to be executed corresponding to the user operation; determining the target task to be executed corresponding to the target operation according to the permission information, and obtaining configuration information of the target task; and creating a corresponding proxy node on the target system according to the configuration information of the target task.
[0011] Optionally, a corresponding proxy node is created on the target system according to the configuration information of the target task, including: obtaining the configuration information of all containers in the target system; obtaining the target interface, wherein the target interface is used to manage and operate resources in the target system; and creating the proxy node according to the configuration information of the target task, the target interface and the configuration information of the target system.
[0012] Optionally, a code building operation is performed according to the proxy node to obtain an execution result, including: calling a first container in the proxy node, wherein the first container is used to communicate with the main node; pulling the target code after the last update from the target code hosting platform according to the configuration information of the target task and the second container, wherein the second container is used to process operations related to code version control; when the target code is successfully obtained, sending the build instructions in the configuration information of the target task to a third container, wherein the build instructions include code compilation instructions, code packaging instructions, and code testing instructions, and the third container is used as a container for performing code building operations; performing a code building operation on the target code according to the build instructions and the third container to obtain an execution result.
[0013] Optionally, after calling the first container in the proxy node, the code management method also includes: using the proxy node to obtain an image, wherein the image is used to start the container in the proxy node; mounting the persistent volume declaration to the proxy node, wherein the persistent volume declaration is used to provide persistent storage resources; and using the first container to register the proxy node to the master node.
[0014] Optionally, in the process of executing the code building operation according to the proxy node to obtain the execution result, the code management method also includes: determining whether there are dependency files required by the target code in the persistent volume declaration, wherein the dependency files are used to provide the resources required in the target code building process; if the dependencies required by the target code do not exist in the persistent volume declaration, obtaining the target dependency library, wherein the target dependency library stores the dependency files required by the target code; obtaining the target dependency files required by the target code from the target dependency library, and caching the target dependency files in the persistent volume declaration.
[0015] Optionally, the execution result is sent to the message display platform via a message plug-in, including: using the message plug-in to obtain the processing result of each stage of the proxy node; and sending the processing result and the execution result to the main node and the message display platform.
[0016] Optionally, after sending the execution result to the message display platform through the message plug-in, the code management method further includes: returning the execution result to the target code hosting platform; and using the master node to deregister the proxy node.
[0017] According to another aspect of the present application, a code management device is also provided, including: a determination unit, which determines the target operation of the target user on the code according to the target code hosting platform, wherein the target code hosting platform is a platform for managing code; a creation unit, which creates a corresponding agent node on the target system according to the target operation, wherein the agent node is used to execute the task assigned by the main node of the target automation tool, and the agent node includes multiple containers, and different containers execute different steps, wherein the target system is used to automatically deploy, manage and coordinate the agent nodes and the main node, and the target automation tool is used to realize code integration and code deployment in software development; an execution unit, which executes the code building operation according to the agent node to obtain the execution result, wherein the code building operation is used to compile the code, run the test, and package and deploy it; a sending unit, which sends the execution result to the message display platform through the message plug-in.
[0018] According to another aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the above-mentioned code management method.
[0019] In the present application, the target operation performed by the target user on the code is first obtained in real time on the target code hosting platform, and then an agent node corresponding to the target operation is created on the target system according to the obtained target operation, wherein the agent node is used to execute the task assigned by the master node in the target automation tool, the target system is used to automatically deploy, manage and coordinate agent nodes and master nodes, and the target automation tool is used to realize code integration and code deployment in software development, indicating that multiple agent nodes and master nodes can be automatically deployed on the target system, each agent node performs corresponding tasks, that is, the agent node can be dynamically created and managed according to the target operation, and each agent node includes multiple containers, and different containers perform different steps. In this way, it can be provided The high continuous integration system has the scalability in resource management and task execution, and then executes the code building operation according to the proxy node to obtain the execution result, wherein the code building operation is used to compile the code, run the test, and package and deploy it, and finally the execution result is sent to the message display platform through the message plug-in. Relevant personnel can view the relevant information of the code building after the target user performs the target operation through the message display platform, thereby achieving the technical effect of improving the timeliness of message feedback of code integration construction and the scalability of continuous integration system in resource management and task execution, thereby solving the technical problems of untimely message feedback of continuous integration execution and limited scalability of Jenkins in resource management and task execution in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 is a flowchart of an optional code management method according to an embodiment of the present application;
[0022] Figure 2 is a schematic diagram of an optional code management method according to an embodiment of the present application;
[0023] Figure 3 is an interaction diagram of an optional code management method according to an embodiment of the present application;
[0024] Figure 4 It is a schematic diagram of an optional code management device according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] It should also be noted that the information and data collected by this application are authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation portals for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or institution through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or institution.
[0028] According to an embodiment of the present application, an embodiment of a code management method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] It should be noted that an intelligent integrated system is used as the execution subject of the code management method of the embodiment of the present application. It is understandable that the code management method provided in the embodiment of the present application can also be executed by other systems or devices, and the embodiment of the present application does not specifically limit this.
[0030] Figure 1is a flowchart of an optional code management method according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0031] Step S101, determining a target operation performed by a target user on the code according to a target code hosting platform.
[0032] In step S101 , the target code hosting platform is a platform for managing codes.
[0033] Optionally, the target code hosting platform is BitBucket, which is a cloud-based version control system mainly used for code hosting.
[0034] Optionally, the target operation includes but is not limited to pushing code, creating a merge request, updating a merge request, creating a branch, and deleting a branch.
[0035] Optionally, the intelligent integration system determines the target operation of the target user through the target code hosting platform.
[0036] Step S102: creating a corresponding proxy node on the target system according to the target operation.
[0037] In step S102, the proxy node is used to execute the task assigned by the master node of the target automation tool. The proxy node includes multiple containers, and different containers execute different steps.
[0038] In step S102, the target system is used to automatically deploy, manage and coordinate agent nodes and master nodes, and the target automation tool is used to implement code integration and code deployment in software development.
[0039] Optionally, the target system is Kubernetes, which is an open source container orchestration platform for automating the deployment, expansion, and management of containerized applications. It provides a framework for running distributed systems, including local and cloud environments. It provides advanced container management capabilities that can seamlessly start, stop, and manage the life cycle of containers. In Kubernetes, Pod (Pod, referring to the minimum deployment unit) is the smallest deployment unit in Kubernetes, and a Pod usually contains one or more containers, and each Pod is independent.
[0040] Optionally, the target automation tool is Jenkins, which is an open source automation server mainly used to automate various software development related tasks, especially continuous integration and continuous deployment. It supports multiple aspects of software development, from building, testing to deployment, and provides a flexible platform to automate almost all types of software development tasks.
[0041] Optionally, the master node and the agent node are two important components of Jenkins. The master node can be represented as Jenkins Master, and the agent node can be represented as Jenkins Slave. Among them, Jenkins Master is the central server of Jenkins, responsible for the operation of the entire Jenkins instance, mainly responsible for the scheduling, distribution and monitoring of tasks, and Jenkins Slave is a working node in the Jenkins architecture, used to execute tasks received from Jenkins Master, such as compiling code, running tests, packaging, etc.
[0042] Optionally, the intelligent integration system deploys Jenkins in Kubernetes. Both Jenkins Master and Jenkins Slave run on the Kubernetes cluster in the form of Pods, and the Pod corresponding to the Jenkins Slave includes multiple containers. Each container executes different steps of the task assigned by the Jenkins Master. Multiple Jenkins Slaves can be created in Kubernete, and different Jenkins Slaves do not interfere with each other.
[0043] Optionally, the intelligent integration system can dynamically create and destroy Jenkins Slave Pods on the Kubernetes cluster according to the needs of the build task, realizing on-demand expansion of resources.
[0044] Optionally, the intelligent integration system creates a corresponding JenkinsMaster on Kubernetes based on the target operation.
[0045] Step S103, executing the code building operation according to the proxy node to obtain an execution result.
[0046] In step S103, the code building operation is used to compile the code, run the test, and package and deploy it.
[0047] Optionally, the intelligent integration system executes the code building operation according to the created Jenkins Slave and obtains relevant information of the execution result.
[0048] Step S104: Send the execution result to the message display platform through the message plug-in.
[0049] Optionally, the message plugin detects the execution status of each stage in the Jenkins Slave in real time.
[0050] Optionally, the intelligent integration system sends relevant information of the execution result to the message display platform for management personnel to view according to the message plug-in.
[0051] It can be seen from the contents of steps S101 to S104 that in the present application, firstly, the target operation of the target user on the code is determined according to the target code hosting platform, wherein the target code hosting platform is a platform for managing code, and secondly, a corresponding agent node is created on the target system according to the target operation, wherein the agent node is used to execute the task assigned by the main node of the target automation tool, and the agent node includes multiple containers, and different containers execute different steps, wherein the target system is used to automatically deploy, manage and coordinate the agent nodes and the main node, and the target automation tool is used to realize code integration and code deployment in software development, and then the code building operation is executed according to the agent node to obtain the execution result, wherein the code building operation is used to compile the code, run the test, and package and deploy it, and finally the execution result is sent to the message display platform through the message plug-in.
[0052] In the present application, the target operation performed by the target user on the code is first obtained in real time on the target code hosting platform, and then an agent node corresponding to the target operation is created on the target system according to the obtained target operation, wherein the agent node is used to execute the task assigned by the master node in the target automation tool, the target system is used to automatically deploy, manage and coordinate agent nodes and master nodes, and the target automation tool is used to realize code integration and code deployment in software development, indicating that multiple agent nodes and master nodes can be automatically deployed on the target system, each agent node performs corresponding tasks, that is, the agent node can be dynamically created and managed according to the target operation, and each agent node includes multiple containers, and different containers perform different steps. In this way, it can be provided The high continuous integration system has the scalability in resource management and task execution, and then executes the code building operation according to the proxy node to obtain the execution result, wherein the code building operation is used to compile the code, run the test, and package and deploy it, and finally the execution result is sent to the message display platform through the message plug-in. Relevant personnel can view the relevant information of the code building after the target user performs the target operation through the message display platform, thereby achieving the technical effect of improving the timeliness of message feedback of code integration construction and the scalability of continuous integration system in resource management and task execution, thereby solving the technical problems of untimely message feedback of continuous integration execution and limited scalability of Jenkins in resource management and task execution in the prior art.
[0053] In an optional embodiment, the intelligent integration system generates event information based on the target operation, wherein the event information refers to data related to the target operation, and then obtains permission information in the event information, wherein the permission information is used to identify the task to be executed corresponding to the user operation, and then determines the target task to be executed corresponding to the target operation based on the permission information, and obtains the configuration information of the target task, and finally creates a corresponding proxy node on the target system based on the configuration information of the target task.
[0054] Optionally, the event information includes at least the user name that triggers the event, the user email address, the name of the warehouse operated, the operation type, the operation time, etc.
[0055] Optionally, BitBucket has a webhook feature, which is an event callback triggered by user operations (such as code submission, merge request creation, etc.) in the Bitbucket repository. When the webhook is configured, Bitbucket will send an HTTP (Hypertext Transfer Protocol) request to the specified URL (Uniform Resource Locator) when these operations occur.
[0056] Optionally, the intelligent integration system performs relevant configuration on Bitbucket. In Bitbucket, you need to set up webhook in the repository setting menu. The key is the URL, which is as follows: http: / / 127.0.0.1:3144 / generic-webhook-trigger / invoke? token=TESTTOKEN, where generic-webhook-trigger means that a plug-in named generic-webhook-trigger is used to receive webhook. The default path it provides is generic-webhook-trigger, which is fixed. Token=TESTTOKEN represents the permission information, which is used to distribute specific tasks.
[0057] Optionally, Jenkins provides a generic-webhook-trigger plug-in for listening to HTTP requests from webhooks. It is characterized by low encapsulation, high customizability and extensibility.
[0058] Optionally, the intelligent integration system performs relevant configurations on Jenkins. Install Plugin: Log in to Jenkins with an administrator account, first click Dashboard, then click Manage Jenkins, then click ManagePlugins, then search for kubernetes, then check kubernetes, Git plugin, Generic Webhook Trigger plugin, and custom message plugin, and finally click Download now and install after restart to install; Configure kubernetes cluster: After the Kubernetes Plugin is installed, click Return to the workbench, then click Manage Jenkins, click Manage Nodes and Clouds, click Configure Clouds, click Add a new cloud, and finally click KubernetesCloud details for configuration; Configure pod template (used to define the properties and parameters for Jenkins to create Jenkins Slave Pods in the Kubernetes cluster): Select the configured Kubernetes cluster, then click Pod Templates, then click Add Pod Templates, and finally click Pod template details for relevant configuration.
[0059] Optionally, Jenkinsfile is a file used to define the build process in the Jenkins continuous integration tool. Here, the Jenkins pipeline job (a job type in Jenkins that supports Jenkinsfile) configuration method is adopted.
[0060] Optionally, Jenkins reads the webhook message configuration code as follows:
[0061]
[0062]
[0063] Optionally, the smart integration system is configured with generic-webhook-trigger to parse the original message according to its parameters, including setting tokens, parsing key parameters, and filtering messages, for example:
[0064] Token configuration: token: 'TOKEN'; Key parameter parsing: Use genericVariables (a method for parsing and capturing data in incoming webhook requests) to parse key parameters based on the source post request (a request type in the HTTP protocol used to send data to the server). It parses by field according to the JSON (JavaScriptObjectNotation) format. The two main types of messages are push (indicating push) and merge (indicating merge). Their fields are different. Except for the common type (indicating the event type or category of the incoming request) and eventKey (indicating the unique identifier or name of the triggering event), the display fields of the two messages after parsing are different. Push messages are usually triggered when the code is pushed to the warehouse. Parsing parameters are for example: pushCommitid (pushed commit ID), pushBranche (pushed branch name), merge message is usually triggered when merge request (or pull request) occurs, parsing parameters such as: mergeCommitid (merged commit ID), mergeBranche (merged branch name), and unrecognized values will be set to default value ('NULL'); message filtering: message filtering uses regexpFilterExpression (a configuration parameter, administrator users need to provide a regular expression) and regexpFilterText (the actual text extracted from the webhook request, which will be used to match the regular expression specified by `regexpFilterExpression`), where regexpFilterText is associated with genericVariables in key parameter parsing. For example, if pushCommitid is defined, then $pushCommitid can be used to read in regexpFilterText, and regexpFilterExpression is a regular expression, and the trigger process will be passed only if it matches the regular expression.In (^repo:refs_changed-((?!master).*)-(ADD|UPDATE)$)|(^pr:merged-NULL-NULL$),|(^pr:merged-NULL-NULL$) indicates that all merge requests are allowed to pass, repo:refs_changed means the message type is push, (ADD|UPDATE) means only DELETE type messages are ignored, ((?!master).*) indicates that only non-master branches are allowed to pass, and the combination indicates that push events of non-DELETE type and branches other than master are matched.
[0065] Optionally, when a specified operation (such as code push, creation of pull request, update of branch, etc.) occurs, Bitbucket generates a corresponding event message according to the operation performed by the user, and sends the event message to Jenkins Master through a hook. Jenkins Master uses the generic-webhook-trigger plug-in to listen to this request and check the token parameter in the request (referring to the above-mentioned permission information). The token parameter is used to determine which specific task is triggered by this request. When the token parameter in the request is the same as the name of a task configured in the generic-webhook-trigger plug-in, it is determined that the task to be executed corresponding to the operation is the task. For example, the generic-webhook-trigger plug-in checks that the token parameter in the request is A, then the task corresponding to the name A configured in the generic-webhook-trigger plug-in is the task that needs to be executed corresponding to the request, and then obtains the configuration information of the task, and finally creates the corresponding Jenkins Slave on the target system according to the configuration information of the task.
[0066] From the above content, we can see that the intelligent integration system realizes a highly automated and flexible continuous integration and continuous deployment process by combining Bitbucket's webhook function and Jenkins' generic-webhook-trigger plug-in. When code submission, merge request creation and other operations are performed in the Bitbucket repository, the webhook will trigger an HTTP request sent to Jenkins. This request contains a token parameter, which serves as permission information and task identifier. It not only ensures the legitimacy of the request, but also helps Jenkins accurately identify and trigger the corresponding build task, and create the corresponding Jenkins Slave according to the task, thereby realizing dynamic allocation and optimization of resources. This integration method improves the speed and accuracy of build and deployment.
[0067] In an optional embodiment, the intelligent integration system first obtains the configuration information of all containers in the target system, then obtains the target interface, wherein the target interface is used to manage and operate the resources in the target system, and finally creates a proxy node according to the configuration information of the target task, the target interface and the configuration information of the target system.
[0068] Optionally, the intelligent integration system obtains configuration information of all containers in the target system (referring to pod template) and configuration information of the target task, and calls the target interface to deploy Jenkins Slave.
[0069] From the above content, it can be seen that the intelligent integration system first obtains the configuration information and target interfaces of all containers running in the target system. Using the collected configuration information and interface access capabilities, the system can accurately and dynamically create proxy nodes, realize highly automated resource management and node deployment, optimize resource utilization efficiency, and improve the scalability and response speed of the system. In addition, this intelligent approach improves the accuracy and reliability of operations, reduces human errors, and allows the system to adapt more flexibly to changing needs and conditions.
[0070] In an optional embodiment, the intelligent integrated system calls the first container in the proxy node, wherein the first container is used to communicate with the main node, and then pulls the target code after the last update from the target code hosting platform according to the configuration information of the target task and the second container, wherein the second container is used to process operations related to code version control, and then, when the target code is successfully obtained, the build instructions in the configuration information of the target task are sent to the third container, wherein the build instructions include code compilation instructions, code packaging instructions, and code testing instructions, and the third container is used as a container for executing code build operations, and finally, the code build operation is performed on the target code according to the build instructions and the third container to obtain an execution result.
[0071] Optionally, the Pod corresponding to the Jenkins Slave includes multiple containers, each of which is responsible for different tasks, and the entire continuous integration and continuous deployment process is automated through collaboration. The first container is the jnlpcontainer (Jenkins Node Launch Protocol Container, Jenkins Slave agent container), which is responsible for communicating with the Jenkins Master and receiving build tasks. The second container is the git container (Git OperationContainer, a Git operation container), which is used to process Git-related operations (referring to a series of commands and activities performed using the Git version control system), such as cloning, pulling, and pushing code. The third container is the build container (BuildContainer, build container), which is used to execute the project's build process, including compilation, packaging, testing, etc.
[0072] Optionally, the target task to be executed is first distributed to the jnlp container of the Jenkins Slave. Subsequently, the jnlp container sends instructions to execute Git operations to the git container. The git container pulls the code from Bitbucket and executes the operation. Once the Git operation is completed, the result is fed back to the jnlp container. If the git operation is successful, the jnlp container will continue to send build instructions to the build container. Finally, the buildcontainer returns the execution result to the jnlp container to ensure the continuity of the entire process and the persistence of data.
[0073] From the above content, it can be seen that the intelligent integration system realizes automated continuous integration and continuous deployment processes through the collaborative work of different containers. First, the system calls the first container that communicates with the master node to coordinate tasks. Secondly, the second container that specializes in code version control is used to pull the latest code from the target code hosting platform. Finally, the build instructions in the task configuration (such as compilation, packaging, and testing) are sent to the third container responsible for executing the build operation. The entire process ensures the automated acquisition, construction, and execution of the code, improving development efficiency and build accuracy.
[0074] In an optional embodiment, the intelligent integration system uses a proxy node to obtain an image, wherein the image is used to start a container in the proxy node, and mounts a persistent volume declaration to the proxy node, wherein the persistent volume declaration is used to provide persistent storage resources, and then uses the first container to register the proxy node to the master node.
[0075] Optionally, the image library is a warehouse that stores Docker images (Docker Container Image), from which Jenkins Slave pulls the image to start running the container, wherein the Docker image is a lightweight, executable software package that contains the code, execution environment, libraries, environment variables and configuration files required to run an application.
[0076] Optionally, the data volume (persistent volume declaration) created by the intelligent integration system in the Kubernetes cluster is mounted to the container in the Jenkins Slave when the Jenkins Slave is started, and serves as a local cache of code build dependencies to speed up code building.
[0077] Optionally, the container in the Pod corresponding to the Jenkins Slave pulls the corresponding image from the image library and starts it, and mounts the PVC (Persistent Volume Claims) to the specified directory to maintain data and dependencies during the build process. At the same time, the jnlp container registers the Jenkins Salve to the Jenkins Master to achieve communication between the Jenkins Salve and the Jenkins Master, ensuring that the build tasks can be smoothly allocated and executed.
[0078] Optionally, PVC needs to be created in advance in the Kubernetes cluster, with the mount path: / home / jenkins / .m2.
[0079] Optionally, the intelligent integration system will create images, including jnlp images, git images, and build images, and push the created images to the image library for subsequent use in container configuration definitions.
[0080] From the above content, we can see that the intelligent integration system can ensure that the build tasks are executed in a consistent and isolated environment by deploying Jenkins Slave in containers and using PVC to achieve data persistence, which improves the flexibility, stability and scalability of the system. At the same time, the communication between the dynamic registration mechanism and the Jenkins Master ensures the smooth allocation and efficient execution of tasks, making the entire integrated deployment process more automated and efficient.
[0081] In an optional embodiment, the intelligent integration system first determines whether there are dependency files required by the target code in the persistent volume declaration, wherein the dependency files are used to provide resources required in the target code construction process. If the dependencies required by the target code do not exist in the persistent volume declaration, the target dependency library is obtained, wherein the target dependency library stores the dependency files required by the target code. The target dependency files required by the target code are then obtained from the target dependency library, and the target dependency files are cached in the persistent volume declaration.
[0082] Optionally, when the intelligent integration system is executing the build process, the build container will check the PVC to confirm whether the required dependencies already exist. If not, the required dependency files will be pulled from the target dependency library and cached in the PVC. If the required dependency files already exist, they will be directly obtained from the PVC.
[0083] From the above content, we can see that the intelligent integration system determines whether it is necessary to pull dependency files from the target dependency library by checking the persistent volume declaration to ensure that the resources required for the build process are available. If the dependency file is missing in the PVC, the system will automatically pull it from the target dependency library and cache it in the PVC for next use; if the dependency file already exists, the system will directly use the file in the PVC, thereby improving build efficiency and optimizing resource usage.
[0084] In an optional embodiment, the intelligent integration system uses a message plug-in to obtain the processing results of each stage of the proxy node, and sends the processing results and execution results to the main node and the message display platform.
[0085] Optionally, the intelligent integration system uses a message plug-in to obtain information related to the processing results of each stage of the proxy node, and sends information related to the processing results of each stage and information related to the execution results to the main node and the message display platform.
[0086] Optionally, the message plug-in sends the acquired information to the message platform in HTTP protocol.
[0087] Optionally, the intelligent integration system develops a custom message plug-in and registers Jenkins' GraphListener listener. The plug-in is divided into three main parts: registration plug-in, listening module and sending module. Once the plug-in is successfully registered, the listening module monitors the jobs executed by Jenkins in real time and collects the execution status; it encapsulates these status information in a custom format and temporarily stores them locally. The specific implementation includes two core functions: first, the start time of the job is captured by extending the FlowExecutionListener class (an interface for listening to and responding to various events during job runtime) and implementing the onRunning method (this method is called when a stage starts to execute); second, the execution message of each stage (referring to the step) is captured by implementing the onNewHead method of the GraphListener interface (representing the listener interface) (this method is called when a new execution node appears), and these messages are filtered and cached locally to reduce transmission overhead. When the stage is completed, the plug-in generates a stage message event based on the cached message. Finally, the sending module sends these events to the predefined message platform through the HTTP protocol, thereby realizing an efficient and flexible Jenkins job status monitoring and message notification system.
[0088] From the above content, it can be seen that the intelligent integration system collects and monitors the processing results of the agent nodes at each stage in real time through the message plug-in, and transmits this key information to the main node and the message display platform, thereby realizing the transparency of the process and instant feedback, ensuring that relevant personnel can understand the execution status and results of the task in a timely manner, and improving the response speed and collaboration efficiency of the entire integrated system.
[0089] In an optional embodiment, the intelligent integration system returns the execution result to the target code hosting platform, and then uses the master node to deregister the proxy node.
[0090] Optionally, the intelligent integration system returns the execution result to Bitbucket, and then uses Jenkins Master to log out of Jenkins Salve.
[0091] Optionally, Bitbucket provides a dedicated API (Applications Programming Interface) for feedback of continuous integration results of a single commit (an operation in Bitbucket used to record and store file changes and related information). In order to safely call this API and avoid leaking the user's real password, Bitbucket supports the use of access tokens for permission verification. When calling the API, users need to attach a valid access token in the request parameters to pass the identity authentication and ensure that the API can feedback the build results of a specific commit based on the provided message field. This mechanism ensures the security of the operation and allows users to customize and view the build status of each code submission.
[0092] Optionally, Jenkins results are synchronized to Bitbuctket through curl (ClientURL, Hypertext Transfer Protocol tool) instructions in the form of API provided by Bitbucket. After synchronization, you can quickly know whether a single commit has completed continuous integration by viewing the commit list. The relevant code is as follows:
[0093] defpostResultToGit(isSuccess){
[0094] if(isTag()){echo "tag does not send results"
[0095] return}
[0096] env.postCommit=getCommitId()
[0097] env.postResult=isSuccess? "SUCCESSFUL":"FAILED";
[0098] sh"'
[0099] curl-kH"Content-Type:application / json"-XPOST-d\
[0100] '{\"state":"'$postResult'",\"key":"'$BUILD_NUMBER'",\"name":"'$JOB_NAME'",\"url":"'$BUILD_URL'"\}'https: / / $USER_NAME:$USER_KEY@host / rest / build-status / 1.0 / commits / ${postCommit}"'}
[0101] defgetCommitId(){
[0102] if(isMarge()){returnenv.mergeCommitid}else{returnenv.pushCommitid}}
[0103] defisTag(){returnenv.pushCommitid==~'refs / tags / .*'}
[0104] / / Judge whether to merge
[0105] defisMerge(){returnenv.mergeBranche! ='NULL'
[0106] }
[0107] Optionally, Figure 2 is a schematic diagram of an optional code management method according to an embodiment of the present application, such as Figure 2 As shown in the figure, the intelligent integration system is mainly based on Jenkins as the core component and is implemented based on Kubernetes multi-node deployment. Jenkins is deployed on Kubernetes, and JenkinsMaster communicates with Bitbucket, JenkinsSalve, and the message platform to achieve self-feedback of messages. JenkinsSalve implements project construction through image libraries, dependency libraries, and PVC, and can achieve the effect of multi-task processing at the same time based on Kubernetes.
[0108] Optionally, Figure 3 is an interactive diagram of an optional code management method according to an embodiment of the present application, such as Figure 3As shown, step 1: Bitbucket generates the corresponding event message according to the user's execution action type, and sends the event message to Jenkins Master through hook; step 2: the generic-webhook-trigger plug-in in Jenkins Master selects the corresponding mapped Job to be executed (referring to the target task) according to the token in the event message, where if the token in the event message is A, the token with the corresponding value of A in the Job is selected; if the token in the event message is B, the token with the corresponding value of B in the Job is selected; step 3: the Job to be executed calls the Kubernetes API (referring to the target interface) to deploy Jenkins Salve according to the job information (referring to the configuration information of the target task) and the pod template configuration (pod configuration information); step 4: then the jnlp container and stage container in Jenkins Salve (referring to the container that executes a specific stage task in the Kubernetes Pod, each stage container can provide different environment configurations to ensure that each stage can be executed in the environment it needs) pull the corresponding image from the image library to start, and mount the PVC to the directory specified by the container in Jenkins Salve; step 5: the jnlp container registers JenkinsSalve to Jenkins On the Master; Step 6: Distribute the job information of the job to be executed to the jnlp container; Step 7: The jnlp container sends the git stage execution instruction (related instructions for obtaining code) defined in the job information to the gitcontainer; Step 8: The git container pulls code from Bitbucket; Step 9: The git container returns the result of the gitstage instruction execution (the result of pulling code) to the jnlp container; Step 10: When the jnlpcontainer receives the result of the successful execution of the git stage instruction, it sends the build stage (related instructions for executing code construction) execution instruction defined in the job information to the build container; Step 11: The build container executes the project build. It should be noted that before executing the project build, it will first check whether the PVC has the required dependencies. If not, it will be pulled from the dependency warehouse and the pulled dependencies will be cached in the PVC. If it exists, it will directly obtain the dependencies from the PVC; Step 12: The build container returns the build stage execution result to the jnlp container;Step 13: The message plug-in detects the execution results of each stage from the jnlp container; Step 14: The message plug-in sends the detected execution results of each stage to the message platform in real time; Step 15: After receiving the result of the job execution completion, the jnlp container returns all the execution results to the Jenkins Master; Step 16: The Jenkins Master feeds back the execution results to Bitbucket and destroys the Jenkins Salve. ;
[0109] From the above content, it can be seen that after executing the build, test or other scheduled tasks, the intelligent integration system can feed back the results to the target code hosting platform, such as Bitbucket, to ensure that all relevant parties can obtain the latest status in real time. After the execution is completed, the system will log out the agent node through the master node to optimize resource management and ensure the cleanliness of the system.
[0110] According to an embodiment of the present application, an embodiment of a code management device is also provided. Figure 4 is a schematic diagram of an optional code management device according to an embodiment of the present application, such as Figure 4 As shown, the code management device includes: a determining unit 401 , a creating unit 402 , an executing unit 403 and a sending unit 404 .
[0111] Optionally, a determination unit 401 is used to determine a target operation of a target user on a code based on a target code hosting platform, wherein the target code hosting platform is a platform for managing code; a creation unit 402 is used to create a corresponding proxy node on a target system based on the target operation, wherein the proxy node is used to execute tasks assigned by a master node of a target automation tool, the proxy node includes multiple containers, and different containers execute different steps, wherein the target system is used to automatically deploy, manage, and coordinate proxy nodes and master nodes, and the target automation tool is used to implement code integration and code deployment in software development; an execution unit 403 is used to execute a code building operation based on the proxy node to obtain an execution result, wherein the code building operation is used to compile, run tests, and package and deploy the code; a sending unit 404 is used to send the execution result to a message display platform through a message plug-in.
[0112] Optionally, the creation unit 402 includes: a first generation subunit, a first acquisition subunit, a first determination subunit, and a first creation subunit. The first generation subunit is used to generate event information according to the target operation, wherein the event information refers to data related to the target operation; the first acquisition subunit is used to obtain permission information in the event information, wherein the permission information is used to identify the task to be executed corresponding to the user operation; the first determination subunit is used to determine the target task to be executed corresponding to the target operation according to the permission information, and obtain the configuration information of the target task; the first creation subunit is used to create a corresponding proxy node on the target system according to the configuration information of the target task.
[0113] Optionally, the first creation subunit includes: a first acquisition module, a second acquisition module and a first creation module. The first acquisition module is used to acquire configuration information of all containers in the target system; the second acquisition module is used to acquire a target interface, wherein the target interface is used to manage and operate resources in the target system; and the first creation module is used to create a proxy node according to the configuration information of the target task, the target interface and the configuration information of the target system.
[0114] Optionally, the execution unit 403 includes: a first calling subunit, a second obtaining subunit, a first sending subunit and a first executing subunit. The first calling subunit is used to call the first container in the proxy node, wherein the first container is used to communicate with the main node; the second obtaining subunit is used to pull the target code after the last update from the target code hosting platform according to the configuration information of the target task and the second container, wherein the second container is used to process operations related to code version control; the first sending subunit is used to send the build instructions in the configuration information of the target task to the third container when the target code is successfully obtained, wherein the build instructions include code compilation instructions, code packaging instructions, and code testing instructions, and the third container is used as a container for executing code build operations; the first executing subunit is used to perform code build operations on the target code according to the build instructions and the third container to obtain an execution result.
[0115] Optionally, the first calling subunit includes: a third acquisition module, a first processing module and a first registration module. The third acquisition module is used to use the proxy node to obtain the image, wherein the image is used to start the container in the proxy node; the first processing module is used to mount the persistent volume declaration to the proxy node, wherein the persistent volume declaration is used to provide persistent storage resources; the first registration module is used to register the proxy node to the master node using the first container.
[0116] Optionally, the execution unit 403 includes: a first judgment subunit, a third acquisition subunit, and a fourth acquisition subunit. The first judgment subunit is used to judge whether there are dependency files required by the target code in the persistent volume declaration, wherein the dependency files are used to provide the resources required in the target code construction process; the third acquisition subunit is used to obtain the target dependency library when there are no dependencies required by the target code in the persistent volume declaration, wherein the target dependency library stores the dependency files required by the target code; the fourth acquisition subunit is used to obtain the target dependency files required by the target code from the target dependency library, and cache the target dependency files in the persistent volume declaration.
[0117] Optionally, the sending unit 404 includes: a fifth acquisition subunit and a second sending subunit. The fifth acquisition subunit is used to use the message plug-in to obtain the processing result of each stage of the proxy node; the second sending subunit is used to send the processing result and the execution result to the main node and the message display platform.
[0118] Optionally, the sending unit 404 includes: a first returning subunit and a first deregistering subunit. The first returning subunit is used to return the execution result to the target code hosting platform; the first deregistering subunit is used to deregister the proxy node using the master node.
[0119] According to another aspect of an embodiment of the present application, a computer-readable storage medium is further provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the above-mentioned code management method.
[0120] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0121] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0122] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0124] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0125] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program code.
[0126] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A code management method, characterized in that: include: Determining a target operation performed by a target user on the code according to a target code hosting platform, wherein the target code hosting platform is a platform for managing code; Creating a corresponding proxy node on the target system according to the target operation, wherein the proxy node is used to perform the task assigned by the master node of the target automation tool, the proxy node includes a plurality of containers, and different containers perform different steps, wherein the target system is used to automatically deploy, manage and coordinate the proxy node and the master node, and the target automation tool is used to implement code integration and code deployment in software development; Executing a code building operation according to the proxy node to obtain an execution result, wherein the code building operation is used to compile, run tests, and package and deploy the code; The execution result is sent to the message display platform through the message plug-in.
2. The code management method according to claim 1, characterized in that: Creating a corresponding proxy node on the target system according to the target operation includes: generating event information according to the target operation, wherein the event information refers to data related to the target operation; Acquire permission information in the event information, wherein the permission information is used to identify the task to be executed corresponding to the user operation; Determine the target task to be executed corresponding to the target operation according to the permission information, and obtain configuration information of the target task; A corresponding proxy node is created on the target system according to the configuration information of the target task.
3. The code management method according to claim 2, characterized in that: Creating a corresponding proxy node on the target system according to the configuration information of the target task includes: Obtaining configuration information of all containers in the target system; Acquire a target interface, wherein the target interface is used to manage and operate resources in the target system; The proxy node is created according to the configuration information of the target task, the target interface and the configuration information of the target system.
4. The code management method according to claim 2, characterized in that: Execute the code building operation according to the proxy node to obtain the execution result, including: Invoke a first container in the proxy node, wherein the first container is used to communicate with the master node; Pull the last updated target code from the target code hosting platform according to the configuration information of the target task and the second container, wherein the second container is used to process operations related to code version control; In the case of successfully acquiring the target code, sending the build instructions in the configuration information of the target task to the third container, wherein the build instructions include code compilation instructions, code packaging instructions, and code testing instructions, and the third container is used as a container for executing the code build operation; The code building operation is performed on the target code according to the building instruction and the third container to obtain the execution result.
5. The code management method according to claim 4, characterized in that: After calling the first container in the proxy node, the code management method further includes: Using the proxy node to obtain an image, wherein the image is used to start a container in the proxy node; Mounting a persistent volume declaration to the proxy node, wherein the persistent volume declaration is used to provide persistent storage resources; The proxy node is registered on the master node using the first container.
6. The code management method according to claim 5, characterized in that: In the process of executing the code building operation according to the proxy node and obtaining the execution result, the code management method further includes: Determine whether there are dependency files required by the target code in the persistent volume declaration, wherein the dependency files are used to provide resources required in the target code construction process; In a case where the dependency required by the target code does not exist in the persistent volume declaration, obtaining a target dependency library, wherein the target dependency library stores dependency files required by the target code; Obtain target dependency files required by the target code from the target dependency library, and cache the target dependency files in the persistent volume declaration.
7. The code management method according to claim 1, characterized in that: Sending the execution result to the message display platform through the message plug-in includes: Using the message plug-in to obtain the processing result of each stage of the proxy node; The processing result and the execution result are sent to the master node and the message display platform.
8. The code management method according to claim 1, characterized in that: After sending the execution result to the message display platform through the message plug-in, the code management method further includes: Returning the execution result to the target code hosting platform; The agent node is deregistered using the master node.
9. A code management device, characterized in that: include: A determination unit, which determines a target operation performed by a target user on the code according to a target code hosting platform, wherein the target code hosting platform is a platform for managing code; a creation unit, which creates a corresponding proxy node on a target system according to the target operation, wherein the proxy node is used to perform tasks assigned by a master node of a target automation tool, the proxy node includes a plurality of containers, and different containers perform different steps, wherein the target system is used to automatically deploy, manage, and coordinate the proxy node and the master node, and the target automation tool is used to implement code integration and code deployment in software development; An execution unit, executing a code building operation according to the proxy node to obtain an execution result, wherein the code building operation is used to compile, run tests, and package and deploy the code; The sending unit sends the execution result to the message display platform through the message plug-in.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the code management method according to any one of claims 1 to 8.
Citation Information
Cited By
Dynamic RBAC permission allocation method based on Kubermeters
CN120723384A