Jenkins cluster calling method and device, equipment and storage medium
Through intelligent routing algorithms and multi-node concurrent submission, the problems of single point failure and unbalanced resource allocation in the Jenkins cluster are solved, and the overall performance and reliability of the Jenkins cluster are improved.
Patent Information
- Application Number
- CN202510505841.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional Jenkins cluster configuration schemes are prone to cause single point failure risk and high concurrent task performance bottlenecks, resulting in low task execution efficiency and system instability, and the deployment cost of multiple master clusters is high and management is complex.
Use intelligent routing algorithm to select scheduling nodes from the Jenkins Master resource pool, use the execution node cluster to execute build scripts and monitor status, or submit requests concurrently to multiple Jenkins Master nodes to achieve high availability and load balancing.
It improves the deployment and management efficiency of Jenkins clusters in multi-Kubernetes environments, solves the problems of single point of failure and unbalanced resource allocation, and improves overall performance and reliability.
Smart Images

Figure CN120371428A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automated deployment, and particularly to a method, device, equipment and storage medium for Jenkins cluster invocation. Background Art
[0002] In the existing technical architecture, Jenkins has become the preferred tool for many development teams due to its wide application in the field of CI / CD (Continuous Integration / Continuous Deployment). However, the traditional Jenkins cluster configuration scheme usually adopts a single Master - multi - Agent architecture mode. This design is prone to performance bottlenecks when facing the single - point failure risk of the Master node and handling high - concurrency task requests, thus affecting the task execution efficiency and system stability, and ultimately hindering the development process.
[0003] Given the complexity of the Jenkins system and the high cost brought by deep customization, directly expanding it into a multi - Master cluster not only has high technical implementation difficulty but also significantly increases the deployment and operation and maintenance costs. In addition, the multi - Master architecture may bring more management challenges and potential risks in practical applications.
[0004] In summary, how to improve the overall performance and reliability of the Jenkins cluster is an urgent problem to be solved at present. Summary of the Invention
[0005] In view of this, the purpose of the present invention is to provide a method, device, equipment and storage medium for Jenkins cluster invocation, which can improve the overall performance and reliability of the Jenkins cluster. The specific solutions are as follows:
[0006] In a first aspect, the present application provides a method for Jenkins cluster invocation, including:
[0007] Receiving a Jenkins request sent by a client and determining the interface type of the Jenkins request; wherein, the interface type is a first interface type or a second interface type;
[0008] If the interface type of the Jenkins request is the first interface type, determining a current scheduling node from the Jenkins Master resource pool according to an intelligent routing algorithm, and submitting the build task of the target task to the current scheduling node to obtain a build script of the target task;
[0009] Execute the build script of the target task using an execution node cluster, monitor the execution status of the build script to obtain a monitoring result, and determine the execution result of the target task based on the monitoring result to complete the Jenkins cluster call;
[0010] If the interface type of the Jenkins request is the second interface type, obtain Jenkins Master nodes that meet the preset available conditions and generate a list of Jenkins Master nodes, concurrently submit Jenkins requests to a preset number of Jenkins Master nodes in the list of Jenkins Master nodes, and perform a preset node call operation according to the obtained submission results to complete the Jenkins cluster call.
[0011] Optionally, the determining the current scheduling node from the Jenkins Master resource pool according to the intelligent routing algorithm includes:
[0012] Determine the cluster health score of Jenkins Master nodes in the Jenkins Master resource pool, and identify the target factors of each Jenkins Master node based on the cluster health score of each Jenkins Master node; wherein, the target factors include any one or several of a preset load status, a preset network latency, and a preset resource utilization rate;
[0013] Determine the target weight of the preset load status based on the cluster health score, and determine the current scheduling node that meets the preset call conditions based on the target weight and the preset load status or preset scheduling rules;
[0014] If there is no Jenkins Master node in the Jenkins Master resource pool that meets the preset call conditions, start a pre-configured standby node and determine the pre-configured standby node as the current scheduling node.
[0015] Optionally, the submitting the build task of the target task to the current scheduling node to obtain the build script of the target task includes:
[0016] Verify whether the corresponding target task project exists in the current scheduling node;
[0017] If the target task project does not exist, create the corresponding target task project so as to submit the build task of the target task to the target Jenkins Master node based on the target task project.
[0018] Optionally, the executing the build script of the target task using the execution node cluster includes:
[0019] Use the execution node cluster to send the build script of the target task to the current scheduling node;
[0020] Monitor the preset health status of the nodes in the execution node cluster, so as to determine the target task execution environment that meets the preset stability conditions based on the obtained monitoring results;
[0021] Based on the target task execution environment, use the conflict-free replicated data type to perform a preset decentralized state management operation on the target task to obtain the build result of executing the build script.
[0022] Optionally, after monitoring the execution status of the build script to obtain the monitoring result, it further includes:
[0023] If the monitoring result indicates that the build script execution fails, stop executing the build script, record the failure result of the target task, and determine the recovery strategy corresponding to the target task according to the failure result, and execute the build script based on the recovery strategy.
[0024] Optionally, determining the recovery strategy corresponding to the target task according to the failure result includes:
[0025] If the failure result of the target task indicates that the target task meets the preset data loss condition, perform a preset data integrity recovery operation to re-execute the build script of the target task;
[0026] If the failure result of the target task indicates that the target task meets the preset service exception condition, activate a preset dynamic repair mechanism to re-execute the build script of the target task;
[0027] If the failure result of the target task indicates that the target task meets the preset cluster-level failure condition, use the CSI volume snapshot and network policy migration technology to transfer the build script of the target task to the pre-configured standby execution node cluster, so as to execute the build script of the target task based on the pre-configured standby execution node cluster;
[0028] If the failure result of the target task indicates that the target task meets the preset extreme failure scenario condition, start a preset Degraded Mode policy and use the Degraded Mode policy to maintain the continuous execution of the target task.
[0029] Optionally, performing a preset node call operation according to the obtained submission result includes:
[0030] If the number of Jenkins Master nodes whose submission results indicate submission failure is greater than the preset failure node number threshold, then re - execute the step of concurrently submitting Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list;
[0031] If the number of Jenkins Master nodes whose submission results indicate submission failure meets the preset failure node number range, then re - execute the step of concurrently submitting Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list through a preset delay queue.
[0032] In a second aspect, the present application provides a Jenkins cluster call device, including:
[0033] An interface determination module, configured to receive a Jenkins request sent by a user - end and determine the interface type of the Jenkins request; wherein, the interface type is a first interface type or a second interface type;
[0034] A script execution module, configured to, if the interface type of the Jenkins request is the first interface type, determine a current scheduling node from a Jenkins Master resource pool according to an intelligent routing algorithm, and submit a build task of a target task to the current scheduling node to obtain a build script of the target task;
[0035] A result determination module, configured to execute the build script of the target task by using an execution node cluster, monitor the execution status of the build script to obtain a monitoring result, and determine the execution result of the target task based on the monitoring result to complete Jenkins cluster call;
[0036] A node call completion module, configured to, if the interface type of the Jenkins request is the second interface type, obtain Jenkins Master nodes that meet the preset available conditions and generate a Jenkins Master node list, concurrently submit Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list, and perform a preset node call operation according to the obtained submission results to complete Jenkins cluster call.
[0037] In a third aspect, the present application provides an electronic device, including:
[0038] A memory, configured to save a computer program;
[0039] A processor for executing the computer program to implement the Jenkins cluster call method as described above.
[0040] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the Jenkins cluster call method as described above is implemented.
[0041] In summary, the present application first receives a Jenkins request sent by a user terminal, and determines the interface type of the Jenkins request; wherein the interface type is a first interface type or a second interface type; if the interface type of the Jenkins request is the first interface type, the current scheduling node is determined from the Jenkins Master resource pool according to the intelligent routing algorithm, and the build task of the target task is submitted to the current scheduling node to obtain the build script of the target task; the build script of the target task is executed by using an execution node cluster, and the execution status of the build script is monitored to obtain a monitoring result, and the execution result of the target task is determined based on the monitoring result to complete the Jenkins cluster call; if the interface type of the Jenkins request is the second interface type, the Jenkins Master node that meets the preset availability conditions is obtained and a Jenkins Master node list is generated, and Jenkins requests are concurrently submitted to the Jenkins Master nodes of the preset number of nodes in the Jenkins Master node list, and the preset node call operation is performed according to the obtained submission result to complete the Jenkins cluster call. As can be seen from the above, this application first receives the Jenkins request sent by the user and determines its interface type (first interface type or second interface type). If it is the first interface type, the current scheduling node is determined from the Jenkins Master resource pool according to the intelligent routing algorithm, the construction task of the target task is submitted to the node to obtain the construction script, the construction script is executed with the execution node cluster and its execution status is monitored to obtain the monitoring result, and then the execution result of the target task is determined based on the monitoring result to complete the Jenkins cluster call; if it is the second interface type, the Jenkins Master node that meets the preset available conditions is obtained and a node list is generated, and the Jenkins request is concurrently submitted to the Jenkins Master nodes with a preset number of nodes in the list, and the preset node call operation is executed according to the obtained submission result, thereby completing the Jenkins cluster call. In this way, this application improves the deployment and management efficiency of Jenkins in a multi-Kubernetes cluster environment, and solves the problem that the Jenkins Master may become a single point of failure and uneven resource allocation in the traditional single Master-multi-Agent architecture by introducing an innovative logical cluster concept. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained according to the provided drawings.
[0043] Figure 1 It is a flowchart of a Jenkins cluster call method disclosed in this application;
[0044] Figure 2 It is a flowchart of a specific Jenkins cluster call method disclosed in this application;
[0045] Figure 3 It is a schematic structural diagram of a Jenkins cluster call device disclosed in this application;
[0046] Figure 4 It is a structural diagram of an electronic device disclosed in this application. Detailed implementation manners
[0047] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0048] Currently, in the existing technical architecture, Jenkins has become the preferred tool for many development teams due to its wide application in the CI / CD field. However, the traditional Jenkins cluster configuration scheme usually adopts a single Master - multi - Agent architecture mode. This design is prone to performance bottlenecks when facing the single - point failure risk of the Master node and processing high - concurrency task requests, thus affecting the task execution efficiency and system stability, and ultimately resulting in the obstruction of the development process. Given the complexity of the Jenkins system and the high cost brought by deep customization, directly expanding it into a multi - Master cluster not only has high technical implementation difficulty but also significantly increases the deployment and operation and maintenance costs. In addition, the multi - Master architecture may bring more management challenges and potential risks in practical applications. To solve the above - mentioned technical problems, this application discloses a Jenkins cluster call method, device, equipment, and storage medium, which can improve the overall performance and reliability of the Jenkins cluster.
[0049] See Figure 1As shown in the figure, an embodiment of the present invention discloses a Jenkins cluster call method, which may include:
[0050] Step S11: Receive a Jenkins request sent by a client and determine the interface type of the Jenkins request; wherein, the interface type is a first interface type or a second interface type.
[0051] In this embodiment, a Jenkins request from a user is received and classified according to the interface type of the Jenkins request. Among them, the interface type of the Jenkins request can be divided into a first interface type and a second interface type. The first interface type mainly involves pipeline operations, including core functions such as task creation, construction, and monitoring. The second interface type covers other functions, such as configuration management, plugin installation, user authentication, and other auxiliary functions.
[0052] Step S12: If the interface type of the Jenkins request is the first interface type, determine the current scheduling node from the Jenkins Master resource pool according to the intelligent routing algorithm, and submit the construction task of the target task to the current scheduling node to obtain the construction script of the target task.
[0053] In this embodiment, when the interface type requested by Jenkins is the first interface type, an intelligent routing algorithm is used to select a suitable node from the dynamically aggregated Jenkins Master resource pool as the current scheduling node. To obtain the current scheduling node, the cluster health score of the Jenkins Master nodes in the Jenkins Master resource pool can be determined, and the target factors of each Jenkins Master node can be identified based on the cluster health score of each Jenkins Master node; wherein, the target factors include any one or several of a preset load status, a preset network latency, and a preset resource utilization rate; the target weight of the preset load status is determined based on the cluster health score, and the current scheduling node that meets the preset call condition is determined based on the target weight and the preset load status or preset scheduling rule; if there is no Jenkins Master node in the Jenkins Master resource pool that meets the preset call condition, the pre-configured standby node is started, and the pre-configured standby node is determined as the current scheduling node. Specifically, the CHI (Cluster Health Index) of each Jenkins Master node in the Jenkins Master resource pool is calculated in real time, and based on the obtained CHI of each Jenkins Master node, factors such as the load status, network latency, and resource utilization rate of the Jenkins Master are comprehensively considered, and the target weight of the preset load status can be dynamically adjusted according to the CHI score. The current scheduling node is determined from the Jenkins Master resource pool according to the target weight or a specific preset scheduling rule configured by the user according to actual requirements. In addition, if there are no available nodes in the Jenkins Master resource pool, the predictive self-healing mechanism will be triggered to start the standby node in advance and notify the operation and maintenance personnel for manual intervention.
[0054] In this embodiment, after determining the current scheduling node, it is verified whether the corresponding target task item exists in the current scheduling node; if the target task item does not exist, the corresponding target task item is created so that the build task of the target task can be submitted to the target Jenkins Master node based on the target task item. Specifically, it is checked whether the target task item already exists in the current scheduling node. If the target task item already exists, there is no need to create it again. If the target task item does not exist, a target task item is created, the build task of the target task is submitted to the current scheduling node to obtain the build script of the target task, and the build script of the target task is loaded using the target task item.
[0055] Step S13: Execute the build script of the target task using the execution node cluster, monitor the execution status of the build script to obtain a monitoring result, and determine the execution result of the target task based on the monitoring result to complete the Jenkins cluster call.
[0056] In this embodiment, after the target task project is created, the execution node cluster is used to send the build script of the target task to the current scheduling node; the preset health status of the nodes in the execution node cluster is monitored so as to determine the target task execution environment that meets the preset stability condition based on the obtained monitoring result; based on the target task execution environment, a preset decentralized state management operation is performed on the target task using the conflict-free replication data type to obtain the build result of executing the build script. Specifically, after the target task project is determined, the Agent cluster is used to execute the build script of the target task to the current scheduling node, and the health status of the Agent nodes in the Agent cluster is monitored to ensure the stability of the task execution environment. The configuration data of the target task is synchronously replicated to other Jenkins Master nodes in the Jenkins Master resource pool in real time, and the conflict-free replication data type is used to implement decentralized state management to avoid the single-point metadata dependency problem of the traditional master-slave architecture. After the current scheduling node obtains the build script of the target task, the build script of the target task is executed to obtain the execution result of executing the build script. In addition, information such as the build status, execution result, and execution log of the target task can be fed back to the user to ensure transparency and traceability.
[0057] In addition, if the monitoring result indicates that the build script execution fails, stop executing the build script, record the failure result of the target task, and determine the recovery strategy corresponding to the target task based on the failure result, and execute the build script based on the recovery strategy. Specifically, if a build failure or timeout is detected, immediately notify the current scheduling node to stop the current target task, record the reason for the target task failure, decide on subsequent operations according to the recovery strategy, and update the load data of the current scheduling node at the same time.
[0058] Further, if the failure result of the target task indicates that the target task meets the preset data loss condition, perform a preset data integrity recovery operation to re-execute the build script of the target task; if the failure result of the target task indicates that the target task meets the preset service exception condition, activate a preset dynamic repair mechanism to re-execute the build script of the target task; if the failure result of the target task indicates that the target task meets the preset cluster-level failure condition, use CSI (Channel State Information) volume snapshots and network policy migration technology to transfer the build script of the target task to a pre-configured standby execution node cluster to execute the build script of the target task based on the pre-configured standby execution node cluster; if the failure result of the target task indicates that the target task meets the preset extreme failure scenario condition, start a preset Degraded Mode policy and use the Degraded Mode policy to maintain the continuous execution of the target task. Specifically, corresponding recovery strategies can be adopted according to the specific reasons for task failure. If data loss occurs, automatically supplement and create the lost data to ensure the feasibility of task recovery. If a service exception occurs, record the exception log and try to recover the service through a predictive self-healing or cross-cluster hot migration mechanism. If a cluster-level failure occurs, trigger cross-cluster hot migration, use CSI volume snapshots and network policy migration technology to transfer the running target task to other available clusters without loss. If an extreme failure scenario occurs, start the Degraded Mode policy and automatically degrade to the minimum available unit to ensure the continuous execution of the core pipeline.
[0059] Step S14, if the interface type of the Jenkins request is the second interface type, obtain Jenkins Master nodes that meet the preset available conditions and generate a Jenkins Master node list, concurrently submit the Jenkins request to a preset number of the Jenkins Master nodes in the Jenkins Master node list, and perform a preset node call operation according to the obtained submission result to complete the Jenkins cluster call.
[0060] In this embodiment, when the interface type of the Jenkins request is the second interface type, obtain all available Jenkins Master nodes from the Jenkins Master resource pool, generate a Jenkins Master node list from these available Jenkins Master nodes, and concurrently submit requests to multiple Jenkins Master nodes in the Jenkins Master node list to ensure the high availability of the task.
[0061] Further, if the number of Jenkins Master nodes whose submission results indicate submission failure is greater than the preset failure node number threshold, the step of concurrently submitting Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list is re-executed; if the number of Jenkins Master nodes whose submission results indicate submission failure meets the preset failure node number range, the step of concurrently submitting Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list is re-executed through a preset delay queue. Specifically, if most requests fail, it will roll back to the initial state and trigger a predictive self-healing mechanism. If a small number of requests fail or some Jenkins Masters are offline, a retry mechanism will be implemented through the delay queue. If it still fails after retrying N times, the operation and maintenance personnel will be notified to intervene and handle it.
[0062] As can be seen from the above, in the embodiment of the present application, first, a Jenkins request sent by the user side is received and its interface type (the first interface type or the second interface type) is determined. If it is the first interface type, the current scheduling node is determined from the Jenkins Master resource pool according to the intelligent routing algorithm, the build task of the target task is submitted to this node to obtain a build script, and the build script is executed by the execution node cluster and its execution status is monitored to obtain a monitoring result, and then the execution result of the target task is determined based on the monitoring result to complete the Jenkins cluster call; if it is the second interface type, Jenkins Master nodes that meet the preset available conditions are obtained and a node list is generated, Jenkins requests are concurrently submitted to the preset number of Jenkins Master nodes in the list, and a preset node call operation is performed according to the obtained submission result, thereby completing the Jenkins cluster call. In this way, the present application improves the deployment and management efficiency of Jenkins in a multi-Kubernetes cluster environment, and solves the problems that Jenkins Master may become a single point of failure and resource allocation imbalance in the traditional single Master - multi-Agent architecture by introducing the innovative concept of a logical cluster.
[0063] Based on the previous embodiment, it can be known that the present application discloses a Jenkins cluster call method, which can improve the overall performance and reliability of the Jenkins cluster. Next, a detailed description will be given of the Jenkins cluster call method as Figure 2 shown.
[0064] First, this application receives Jenkins requests from users and classifies them according to the interface types of the Jenkins requests. Among them, the interface types of the Jenkins requests can be divided into a first interface type and a second interface type.
[0065] When the interface type of the Jenkins request is the first interface type, an intelligent routing algorithm is used to select a suitable node from the dynamically aggregated Jenkins Master resource pool as the current scheduling node. After determining the current scheduling node, a target task project is created, and the build task of the target task is submitted to the current scheduling node to obtain the build script of the target task, and the target task project is used to load the build script of the target task. Subsequently, the build script of the target task is executed, and the Agent cluster is used to execute the build script of the target task on the current scheduling node, and the health status of the Agent nodes in the Agent cluster is monitored to obtain the execution result of executing the build script. If the monitoring result indicates a failure or an exception in the execution, a preset recovery strategy is executed to complete the execution of the build script of the target task.
[0066] When the interface type of the Jenkins request is the second interface type, all available Jenkins Master nodes are obtained from the Jenkins Master resource pool, and a JenkinsMaster node list is generated from these available Jenkins Master nodes. A request is concurrently submitted to a preset number of JenkinsMaster nodes in the JenkinsMaster node list, and a preset node call operation is executed according to the obtained submission result.
[0067] See Figure 3 As shown, an embodiment of the present invention discloses a Jenkins cluster call device, including:
[0068] An interface determination module 11, configured to receive a Jenkins request sent by a user terminal and determine the interface type of the Jenkins request; wherein, the interface type is a first interface type or a second interface type;
[0069] A script execution module 12, configured to, if the interface type of the Jenkins request is the first interface type, determine a current scheduling node from the Jenkins Master resource pool according to an intelligent routing algorithm, and submit the build task of the target task to the current scheduling node to obtain the build script of the target task;
[0070] A result determination module 13 is used to execute the build script of the target task using the execution node cluster, monitor the execution status of the build script to obtain a monitoring result, and determine the execution result of the target task based on the monitoring result to complete the Jenkins cluster call;
[0071] The node call completion module 14 is used to obtain the Jenkins Master node that meets the preset availability conditions and generate a Jenkins Master node list if the interface type of the Jenkins request is the second interface type, concurrently submit Jenkins requests to the Jenkins Master nodes with a preset number of nodes in the Jenkins Master node list, and execute the preset node call operation according to the obtained submission results to complete the Jenkins cluster call.
[0072] As can be seen from the above, this application first receives the Jenkins request sent by the user and determines its interface type (first interface type or second interface type). If it is the first interface type, the current scheduling node is determined from the Jenkins Master resource pool according to the intelligent routing algorithm, the construction task of the target task is submitted to the node to obtain the construction script, the construction script is executed with the execution node cluster and its execution status is monitored to obtain the monitoring result, and then the execution result of the target task is determined based on the monitoring result to complete the Jenkins cluster call; if it is the second interface type, the Jenkins Master node that meets the preset available conditions is obtained and a node list is generated, and the Jenkins request is concurrently submitted to the Jenkins Master nodes with a preset number of nodes in the list, and the preset node call operation is executed according to the obtained submission result, thereby completing the Jenkins cluster call. In this way, this application improves the deployment and management efficiency of Jenkins in a multi-Kubernetes cluster environment, and solves the problem that the Jenkins Master may become a single point of failure and uneven resource allocation in the traditional single Master-multi-Agent architecture by introducing an innovative logical cluster concept.
[0073] In some specific implementations, the script execution module 12 may specifically include:
[0074] A target factor identification unit, used to determine the cluster health score of the Jenkins Master node in the Jenkins Master resource pool, and identify the target factor of each Jenkins Master node based on the cluster health score of each Jenkins Master node; wherein the target factor includes any one or more of a preset load state, a preset network delay, and a preset resource utilization rate;
[0075] A first current scheduling node determination unit, configured to determine a target weight of the preset load state based on the cluster health score, and determine a current scheduling node that meets the preset call condition based on the target weight and the preset load state or preset scheduling rule;
[0076] A second current scheduling node determination unit, configured to, if there is no Jenkins Master node that meets the preset call condition in the Jenkins Master resource pool, start a pre-set spare node and determine the pre-set spare node as the current scheduling node.
[0077] In some specific embodiments, the script execution module 12 may specifically include:
[0078] A target task item verification unit, configured to verify whether a corresponding target task item exists in the current scheduling node;
[0079] A target task item creation unit, configured to, if the target task item does not exist, create a corresponding target task item, so as to submit a build task of the target task to a target Jenkins Master node based on the target task item.
[0080] In some specific embodiments, the result determination module 13 may specifically include:
[0081] A build script sending unit, configured to send a build script of the target task to the current scheduling node by using an execution node cluster;
[0082] A target task execution environment determination unit, configured to monitor a preset health state of nodes in the execution node cluster, so as to determine a target task execution environment that meets a preset stability condition based on the obtained monitoring result;
[0083] A build result acquisition unit, configured to perform a preset decentralized state management operation on the target task by using a conflict-free replicated data type based on the target task execution environment, so as to obtain a build result of executing the build script.
[0084] In some specific embodiments, the Jenkins cluster calling device may further include:
[0085] A build script execution module, configured to, if the monitoring result indicates that the execution of the build script fails, stop executing the build script, record a failure result of the target task, and determine a recovery strategy corresponding to the target task according to the failure result, and execute the build script based on the recovery strategy.
[0086] In some specific embodiments, the build script execution module may specifically include:
[0087] A first build script execution failure determination unit, configured to perform a preset data integrity restoration operation if the failure result of the target task indicates that the target task meets a preset data loss condition, so as to re-execute the build script of the target task;
[0088] A second build script execution failure determination unit, configured to activate a preset dynamic repair mechanism if the failure result of the target task indicates that the target task meets a preset service exception condition, so as to re-execute the build script of the target task;
[0089] A third build script execution failure determination unit, configured to use CSI volume snapshot and network policy migration technology to transfer the build script of the target task to a pre-configured standby execution node cluster if the failure result of the target task indicates that the target task meets a preset cluster-level failure condition, so as to execute the build script of the target task based on the pre-configured standby execution node cluster;
[0090] A fourth build script execution failure determination unit, configured to start a preset Degraded Mode policy and use the Degraded Mode policy to maintain the continuous execution of the target task if the failure result of the target task indicates that the target task meets a preset extreme failure scenario condition.
[0091] In some specific embodiments, the node call completion module 14 may specifically include:
[0092] A first submission failure determination unit, configured to re-execute the step of concurrently submitting a Jenkins request to a preset number of Jenkins Master nodes in the Jenkins Master node list if the submission result indicates that the number of Jenkins Master nodes with submission failures is greater than a preset failure node number threshold;
[0093] A second submission failure determination unit, configured to re-execute the step of concurrently submitting a Jenkins request to a preset number of Jenkins Master nodes in the Jenkins Master node list through a preset delay queue if the submission result indicates that the number of Jenkins Master nodes with submission failures meets a preset failure node number range.
[0094] Furthermore, an embodiment of the present application also discloses an electronic device, Figure 4 which is a structural diagram of an electronic device 20 shown according to an exemplary embodiment, and the content in the figure should not be considered as any limitation to the scope of use of the present application.
[0095] Figure 4 This is a schematic structural diagram of an electronic device 20 provided by an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the Jenkins cluster call method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0096] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of the present application, and specific limitations are not imposed here; the input / output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and specific limitations are not made here.
[0097] In addition, as a carrier for resource storage, the memory 22 may be a read-only memory, a random access memory, a disk, or an optical disc, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.
[0098] Among them, the operating system 221 is used to manage and control each hardware device and the computer program 222 on the electronic device 20, and it may be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the Jenkins cluster call method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program that can be used to complete other specific tasks.
[0099] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the Jenkins cluster call method disclosed above is implemented. For the specific steps of this method, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not repeated here.
[0100] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For related parts, reference can be made to the description in the method section.
[0101] Those skilled in the art can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of the examples have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0102] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be directly implemented by hardware, software modules executed by a processor, or a combination of both. The software modules can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0103] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.
[0104] The technical solutions provided in this application have been introduced in detail above. Specific examples are used herein to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.
Claims
1. A Jenkins cluster invocation method, characterized in that, Including: Receiving a Jenkins request sent by a user terminal and determining the interface type of the Jenkins request; wherein, the interface type is a first interface type or a second interface type; If the interface type of the Jenkins request is the first interface type, determining a current scheduling node from a Jenkins Master resource pool according to an intelligent routing algorithm, and submitting a build task of a target task to the current scheduling node to obtain a build script of the target task; Using an execution node cluster to execute the build script of the target task, monitoring the execution status of the build script to obtain a monitoring result, and determining an execution result of the target task based on the monitoring result to complete Jenkins cluster invocation; If the interface type of the Jenkins request is the second interface type, obtaining Jenkins Master nodes that meet preset available conditions and generating a Jenkins Master node list, concurrently submitting Jenkins requests to a preset number of Jenkins Master nodes in the Jenkins Master node list, and performing a preset node invocation operation according to the obtained submission result to complete Jenkins cluster invocation.
2. The Jenkins cluster invocation method according to claim 1, wherein The determining a current scheduling node from a Jenkins Master resource pool according to an intelligent routing algorithm includes: Determining a cluster health score of Jenkins Master nodes in a Jenkins Master resource pool, and identifying target factors of each Jenkins Master node based on the cluster health scores of each Jenkins Master node; wherein, the target factors include any one or several of a preset load status, a preset network latency, and a preset resource utilization rate; Determining a target weight of the preset load status based on the cluster health score, and determining a current scheduling node that meets a preset invocation condition based on the target weight and the preset load status or a preset scheduling rule; If there is no Jenkins Master node in the Jenkins Master resource pool that meets the preset invocation condition, starting a pre-configured standby node and determining the pre-configured standby node as the current scheduling node.
3. The Jenkins cluster invocation method according to claim 1, wherein, The submitting a build task of a target task to the current scheduling node to obtain a build script of the target task includes: Verifying whether a corresponding target task project exists in the current scheduling node; If the target task project does not exist, creating a corresponding target task project so as to submit the build task of the target task to a target Jenkins Master node based on the target task project.
4. The Jenkins cluster invocation method according to claim 1, wherein The using an execution node cluster to execute the build script of the target task includes: Using an execution node cluster to send the build script of the target task to the current scheduling node; Monitor the preset health status of the nodes in the execution node cluster, so as to determine a target task execution environment that meets the preset stability conditions based on the obtained monitoring results; Based on the target task execution environment, perform a preset decentralized state management operation on the target task using conflict-free replicated data types to obtain a build result for executing the build script.
5. The Jenkins cluster invocation method according to claim 1, wherein, After monitoring the execution status of the build script to obtain a monitoring result, it further includes: If the monitoring result indicates that the build script execution fails, stop executing the build script, record the failure result of the target task, determine a recovery strategy corresponding to the target task according to the failure result, and execute the build script based on the recovery strategy.
6. The Jenkins cluster call method according to claim 5, wherein, Determining the recovery strategy corresponding to the target task according to the failure result includes: If the failure result of the target task indicates that the target task meets the preset data loss condition, perform a preset data integrity recovery operation to re-execute the build script of the target task; If the failure result of the target task indicates that the target task meets the preset service exception condition, activate a preset dynamic repair mechanism to re-execute the build script of the target task; If the failure result of the target task indicates that the target task meets the preset cluster-level failure condition, use CSI volume snapshot and network policy migration technology to transfer the build script of the target task to a pre-configured standby execution node cluster, and execute the build script of the target task based on the pre-configured standby execution node cluster; If the failure result of the target task indicates that the target task meets the preset extreme failure scenario condition, start a preset Degraded Mode strategy and use the Degraded Mode strategy to maintain the continuous execution of the target task.
7. The Jenkins cluster invocation method according to any one of claims 1 to 6, characterized in that, Performing a preset node call operation according to the obtained submission result includes: If the submission result indicates that the number of Jenkins Master nodes with submission failures is greater than the preset failure node number threshold, re-execute the step of concurrently submitting Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list; If the submission result indicates that the number of Jenkins Master nodes with submission failures meets the preset failure node number range, re-execute the step of concurrently submitting Jenkins requests to the preset number of Jenkins Master nodes in the Jenkins Master node list through a preset delay queue.
8. A Jenkins cluster call device, characterized in that, It includes: An interface determination module, configured to receive a Jenkins request sent by a user terminal and determine the interface type of the Jenkins request; wherein, the interface type is a first interface type or a second interface type; A script execution module, which is configured to, if the interface type of the Jenkins request is the first interface type, determine a current scheduling node from the Jenkins Master resource pool according to an intelligent routing algorithm, and submit a build task of a target task to the current scheduling node to obtain a build script of the target task; A result determination module, which is configured to execute the build script of the target task by using an execution node cluster, monitor the execution status of the build script to obtain a monitoring result, and determine the execution result of the target task based on the monitoring result, so as to complete the Jenkins cluster call; A node call completion module, which is configured to, if the interface type of the Jenkins request is the second interface type, obtain Jenkins Master nodes that meet preset available conditions and generate a Jenkins Master node list, concurrently submit Jenkins requests to a preset number of the Jenkins Master nodes in the Jenkins Master node list, and execute a preset node call operation according to the obtained submission results, so as to complete the Jenkins cluster call.
9. An electronic device, characterized in that, Comprising: A memory, which is used for storing a computer program; A processor, which is used for executing the computer program to implement the Jenkins cluster call method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, For storing a computer program; wherein, when the computer program is executed by the processor, the Jenkins cluster call method according to any one of claims 1 to 7 is implemented.