Jenkins assembly line management method and device and storage medium
By generating or clearing webhooks in the Jenkins pipeline, obtaining branch code information and managing task information, and using the delay queue to process delay tasks, the problems of poor security and low management efficiency of the Jenkins pipeline are solved, and higher security and stability are achieved.
Patent Information
- Application Number
- CN202410010199.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-03
- Publication Date
- 2025-07-04
AI Technical Summary
The existing Jenkins pipeline has problems such as poor security and low management efficiency. Especially when back-end technicians update shared code bases, the pipeline is easily triggered automatically, resulting in high concurrency problems.
By responding to the save command of the target pipeline, we judge whether the pollSCM function is started and generate or clear the webhook; obtain branch code information based on the target hosting platform, judge the change situation, send task information calling instructions, receive and manage task information, and use the delay queue to process delay tasks to avoid high concurrency.
Enhanced permission control of pipelines, improve data security and management efficiency, avoid high concurrency problems, and ensure the stability and performance of Jenkins pipelines.
Smart Images

Figure CN120256035A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technologies, and in particular, to a method, device, and storage medium for managing Jenkins pipelines. Background Art
[0002] Jenkins is an open-source automation tool written in Java, with plugins for continuous integration. Jenkins is used for continuous building and testing of software, making it easier for developers to integrate changes into the software and for users to obtain new builds. It also allows for continuous inheritance and continuous delivery of software. With the continuous development of the software industry, enterprises have higher and higher requirements for the speed and quality of software delivery. The traditional software development and operation and maintenance processes consume a large amount of manpower and time and are prone to errors. Therefore, Jenkins pipelines have received extensive attention and application.
[0003] Currently, for a Jenkins pipeline, it is first necessary to define the stages and tasks of the pipeline. Each stage represents a step in the software development and operation and maintenance process, such as code checkout, compilation, testing, and deployment. Each task is a specific operation to be performed in that stage. After defining the pipeline, it is necessary to configure Jenkins to achieve automated execution of the pipeline, which includes configuring the Jenkins server, installing and configuring various tools and plugins, and setting the trigger mechanism. During the configuration process, it is necessary to adjust the parameters and options of the pipeline according to the actual situation to ensure the normal operation of the pipeline. When the Jenkins server starts and receives a trigger signal, the pipeline starts to execute. Each stage sequentially executes the corresponding tasks in the defined order. During the execution process, Jenkins records the execution status and results of each task for subsequent analysis and monitoring.
[0004] Due to the existing technology, when backend technical personnel update the shared code library, the pipeline corresponding to the enabled pollSCM function will be automatically triggered to run, resulting in huge security problems for the user's pipeline. Therefore, the data security of the pipeline needs to be improved. At the same time, if there are tens of thousands of pipelines using this function, due to the change of the shared code library, these tens of thousands of pipelines will be triggered simultaneously, causing high concurrency problems. Therefore, the existing technology has technical problems of poor security and low management efficiency of Jenkins pipelines. Summary of the Invention
[0005] This application provides a method, device, and storage medium for managing Jenkins pipelines to solve the technical problems of poor security and low management efficiency of Jenkins pipelines in the existing technology.
[0006] In a first aspect, this application provides a method for managing a Jenkins pipeline, the method including:
[0007] Process the webhook of the target pipeline in response to the save instruction of the target pipeline;
[0008] Determine the corresponding target hosting platform and the corresponding branch code based on the target pipeline, and obtain the code information of the branch code based on a preset rule; judge whether the branch code has changed based on the code information; if so, send a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook;
[0009] Receive the task information fed back by the service interface, and manage the target pipeline based on the task information.
[0010] Optionally, processing the webhook of the target pipeline in response to the save instruction of the target pipeline includes:
[0011] Judge whether the pollSCM function of the target pipeline is started in response to the save instruction of the target pipeline;
[0012] If so, judge whether the target pipeline has already generated a webhook;
[0013] If the webhook has not been generated, generate the webhook corresponding to the target pipeline.
[0014] Optionally, the method further includes:
[0015] When the pollSCM function of the target pipeline is not started, judge whether the target pipeline has already generated a webhook;
[0016] If the webhook has been generated, clear the webhook corresponding to the target pipeline.
[0017] Optionally, receiving the task information fed back by the service interface and managing the target pipeline based on the task information includes:
[0018] Receive the task information fed back by the service interface, and judge whether the task information meets the preset conditions; among them, the task information includes code change information and the running status information of the target pipeline;
[0019] If so, manage the target pipeline based on the code change information and the running status information according to the pollSCM function.
[0020] Optionally, managing the target pipeline based on the code change information and the running status information according to the pollSCM function includes:
[0021] Judge whether a delay task has been pushed into the target pipeline based on the pollSCM function;
[0022] If not, generate a target delayed task according to the code change information and the running status information, and push the target delayed task into the first thread of the target pipeline for running.
[0023] Optionally, generating a target delayed task according to the code change information and the running status information includes:
[0024] Based on the delay queue function, parse the target execution time from the corn expression according to the code change information and the running status information;
[0025] Generate a target delayed task based on the target execution time.
[0026] Optionally, after pushing the target delayed task into the target pipeline for running, it includes:
[0027] Obtain the current execution time of the target delayed task, and determine whether the current execution time is greater than or equal to a preset threshold;
[0028] If so, based on the delay queue function, take out the target delayed task from the delay queue, and push the target delayed task into the second thread of the target pipeline for running.
[0029] In the second aspect of the present application, a management device for a Jenkins pipeline is provided, including:
[0030] A response module, in response to a save instruction of the target pipeline, processes the webhook of the target pipeline;
[0031] A first processing module, based on the target pipeline, determines the corresponding target hosting platform and the corresponding branch code, and obtains the code information of the branch code based on a preset rule; determines whether the branch code has changed based on the code information; if so, sends a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook;
[0032] A second processing module, receives the task information fed back by the service interface, and manages the target pipeline based on the task information.
[0033] Optionally, the response module is further configured to:
[0034] In response to a save instruction of the target pipeline, determine whether the pollSCM function of the target pipeline is started;
[0035] If so, determine whether the target pipeline has already generated a webhook;
[0036] If the webhook has not been generated, generate the webhook corresponding to the target pipeline.
[0037] Optionally, the response module is further configured to:
[0038] When the pollSCM function of the target pipeline is not started, it is determined whether the target pipeline has generated a webhook;
[0039] If a webhook has been generated, the webhook corresponding to the target pipeline is cleared.
[0040] Optionally, the second processing module is further configured to:
[0041] Receive task information fed back by the service interface, and determine whether the task information meets a preset condition; wherein, the task information includes code change information and the running status information of the target pipeline;
[0042] If so, manage the target pipeline based on the pollSCM function according to the code change information and the running status information.
[0043] Optionally, the second processing module is further configured to:
[0044] Based on the pollSCM function, determine whether a delay task has been pushed into the target pipeline;
[0045] If not, generate a target delay task according to the code change information and the running status information, and push the target delay task into the first thread of the target pipeline for running.
[0046] Optionally, the second processing module is further configured to:
[0047] Based on the delay queue function, parse the target execution time from the corn expression according to the code change information and the running status information;
[0048] Generate a target delay task based on the target execution time.
[0049] Optionally, the second processing module is further configured to:
[0050] Obtain the current execution time of the target delay task, and determine whether the current execution time is greater than or equal to a preset threshold;
[0051] If so, based on the delay queue function, take out the target delay task from the delay queue, and push the target delay task into the second thread of the target pipeline for running.
[0052] In a third aspect, the present application provides a management device for a Jenkins pipeline, including: a processor, and a memory communicatively connected to the processor, including:
[0053] The memory stores computer-executable instructions;
[0054] The processor executes computer-executable instructions stored in the memory to implement the management method of the Jenkins pipeline in the first aspect.
[0055] In a fourth aspect, a computer-readable storage medium stores computer-executable instructions, which are used to implement the management method of the Jenkins pipeline in the first aspect when executed by a processor.
[0056] A management method, device, and storage medium for a Jenkins pipeline provided in this application, in response to a save instruction for a target pipeline, determine whether the pollSCM function of the target pipeline is started; if so, determine whether a webhook has been generated for the target pipeline; if no webhook has been generated, generate a webhook corresponding to the target pipeline; when the pollSCM function of the target pipeline is not started, determine whether a webhook has been generated for the target pipeline; if a webhook has been generated, clear the webhook corresponding to the target pipeline; determine a corresponding target hosting platform and corresponding branch code based on the target pipeline, and obtain code information of the branch code based on a preset rule; determine whether the branch code has changed based on the code information; if so, send a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook; receive the task information fed back by the service interface, and determine whether the task information meets a preset condition; where the task information includes code change information and the running status information of the target pipeline; determine whether a delay task has been pushed into the target pipeline based on the pollSCM function; if not, parse a target execution time from a corn expression based on the code change information and the running status information according to the delay queue function; generate a target delay task based on the target execution time, and push the target delay task into the first thread of the target pipeline for execution; obtain the current execution time of the target delay task, and determine whether the current execution time is greater than or equal to a preset threshold; if so, take out the target delay task from the delay queue based on the delay queue function, and push the target delay task into the second thread of the target pipeline for execution, thereby enhancing the permission control of the pipeline, preventing backend technicians from running user pipelines, increasing data security, improving the stability of each deployment environment, and avoiding possible high-concurrency problems that may affect the performance of Jenkins, achieving the technical effect of improving the security and management efficiency of the Jenkins pipeline. Description of the Drawings
[0057] The drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with this application, and are used together with the specification to explain the principles of this application.
[0058] Figure 1Flowchart of the Jenkins pipeline management method provided by the embodiments of the present application Figure 1 ;
[0059] Figure 2 Flowchart of the Jenkins pipeline management method provided by the embodiments of the present application Figure 2 ;
[0060] Figure 3 Flowchart of the Jenkins pipeline management method provided by the embodiments of the present application Figure 3 ;
[0061] Figure 4 Flowchart of the Jenkins pipeline management method provided by the embodiments of the present application Figure 4 ;
[0062] Figure 5 Flowchart for saving the Jenkins pipeline in the Jenkins pipeline management method provided by the embodiments of the present application;
[0063] Figure 6 Flowchart for deleting the Jenkins pipeline in the Jenkins pipeline management method provided by the embodiments of the present application;
[0064] Figure 7 Producer - consumer model diagram of the Jenkins pipeline management method provided by the embodiments of the present application;
[0065] Figure 8 Structure schematic diagram of the Jenkins pipeline management device provided by the embodiments of the present application;
[0066] Figure 9 Hardware schematic diagram of the Jenkins pipeline management device provided by the embodiments of the present application.
[0067] Through the above - mentioned drawings, the clear embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and written descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed implementation manners
[0068] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0069] Since in the prior art, when backend technicians update the shared code repository and the pipeline corresponding to the pollSCM function is enabled, it will automatically trigger and run, resulting in huge security problems for the user's pipeline. Therefore, the data security of the pipeline needs to be improved. At the same time, if there are tens of thousands of pipelines using this function, due to the change of the shared code repository, these tens of thousands of pipelines will be triggered simultaneously, causing high concurrency problems. Therefore, the prior art has the technical problems of poor security and low management efficiency of Jenkins pipelines.
[0070] A management method, device, and storage medium for Jenkins pipelines provided by this application, in response to a save instruction of a target pipeline, determine whether the pollSCM function of the target pipeline is started; if so, determine whether a webhook has been generated for the target pipeline; if no webhook has been generated, generate a webhook corresponding to the target pipeline; when the pollSCM function of the target pipeline is not started, determine whether a webhook has been generated for the target pipeline; if a webhook has been generated, clear the webhook corresponding to the target pipeline; determine the corresponding target hosting platform and the corresponding branch code based on the target pipeline, and obtain the code information of the branch code based on a preset rule; determine whether the branch code has changed based on the code information; if so, send a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook; receive the task information fed back by the service interface, and determine whether the task information meets the preset conditions; where the task information includes code change information and the running status information of the target pipeline; determine whether a delay task has been pushed into the target pipeline based on the pollSCM function; if not, parse the target execution time from the corn expression based on the code change information and the running status information according to the delay queue function; generate a target delay task based on the target execution time, and push the target delay task into the first thread of the target pipeline for running; obtain the current execution time of the target delay task, and determine whether the current execution time is greater than or equal to a preset threshold; if so, take out the target delay task from the delay queue based on the delay queue function, and push the target delay task into the second thread of the target pipeline for running, thereby enhancing the permission control of the pipeline. Backend technicians should not run the user's pipeline, increasing data security, improving the stability of each deployment environment, and at the same time avoiding possible high concurrency problems that affect the performance of Jenkins, achieving the technical effect of improving the security and management efficiency of Jenkins pipelines.
[0071] The following uses specific embodiments to elaborate in detail on the technical solutions of this application and how the technical solutions of this application solve the above technical problems. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of this application in conjunction with the accompanying drawings.
[0072] Figure 1 The management method process of the Jenkins pipeline provided by the embodiment of the present application Figure 1 As Figure 1 shown, the management method of the Jenkins pipeline provided by this embodiment includes:
[0073] S101. In response to the save instruction of the target pipeline, process the webhook of the target pipeline;
[0074] In this embodiment, the content of processing the webhook of the target pipeline when saving the target pipeline is as Figure 5 shown. It is necessary to judge whether the pollSCM function of the target pipeline is started; if so, judge whether the target pipeline has generated a webhook; if the webhook has not been generated, generate the webhook corresponding to the target pipeline; when the pollSCM function of the target pipeline is not started, judge whether the target pipeline has generated a webhook, if the webhook has been generated, clear the webhook corresponding to the target pipeline; judge whether the target pipeline already has a delayed task, if there is a delayed task, clear the delayed task corresponding to the target pipeline; the content of processing the webhook of the target pipeline when deleting the target pipeline is as Figure 6 shown. It is necessary to judge whether the pollSCM function of the target pipeline is started; if so, judge whether the target pipeline has generated a webhook; if the webhook has been generated, clear the webhook corresponding to the target pipeline, and then judge whether the target pipeline already has a delayed task, if there is a delayed task, clear the delayed task corresponding to the target pipeline; the webhook is set to push event and merge event.
[0075] S102. Determine the corresponding target hosting platform and the corresponding branch code based on the target pipeline, and obtain the code information of the branch code based on the preset rules; judge whether the branch code has changed based on the code information; if so, send a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook;
[0076] S103. Receive the task information fed back by the service interface, and manage the target pipeline based on the task information.
[0077] A management method for Jenkins pipelines provided by this application responds to a save instruction for a target pipeline, and determines whether the pollSCM function of the target pipeline is started; if so, it determines whether a webhook has been generated for the target pipeline; if no webhook has been generated, it generates a webhook corresponding to the target pipeline; when the pollSCM function of the target pipeline is not started, it determines whether a webhook has been generated for the target pipeline; if a webhook has been generated, it clears the webhook corresponding to the target pipeline; determines the corresponding target hosting platform and the corresponding branch code based on the target pipeline, and obtains the code information of the branch code based on a preset rule; determines whether the branch code has changed based on the code information; if so, sends a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook; receives the task information fed back by the service interface, and determines whether the task information meets the preset conditions; where the task information includes code change information and the running status information of the target pipeline; determines whether a delay task has been pushed into the target pipeline based on the pollSCM function; if not, parses the target execution time from the corn expression based on the code change information and the running status information according to the delay queue function; generates a target delay task based on the target execution time, and pushes the target delay task into the first thread of the target pipeline for running; obtains the current execution time of the target delay task, and determines whether the current execution time is greater than or equal to a preset threshold; if so, takes out the target delay task from the delay queue based on the delay queue function, and pushes the target delay task into the second thread of the target pipeline for running, thereby enhancing the permission control of the pipeline, preventing backend technicians from running user pipelines, increasing data security, improving the stability of each deployment environment, and avoiding possible high-concurrency problems that affect the performance of Jenkins, achieving the technical effect of improving the security and management efficiency of Jenkins pipelines.
[0078] Figure 2 The flow of the management method for Jenkins pipelines provided by the embodiments of this application Figure 2 As Figure 2 shown, the management method for Jenkins pipelines provided by this embodiment includes:
[0079] S201. In response to a save instruction for a target pipeline, determine whether the pollSCM function of the target pipeline is started; if so, determine whether a webhook has been generated for the target pipeline; if no webhook has been generated, generate a webhook corresponding to the target pipeline;
[0080] S202. When the pollSCM function of the target pipeline is not started, determine whether the target pipeline has generated a webhook. If a webhook has been generated, clear the webhook corresponding to the target pipeline.
[0081] S203. Based on the target pipeline, determine the corresponding target hosting platform and the corresponding branch code, and obtain the code information of the branch code based on a preset rule. Determine whether the branch code has changed based on the code information. If so, send a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook.
[0082] S204. Receive the task information fed back by the service interface, and determine whether the task information meets the preset conditions. Among them, the task information includes code change information and the running status information of the target pipeline.
[0083] S205. Based on the pollSCM function, determine whether a delay task has been pushed into the target pipeline. If not, based on the delay queue function, parse the target execution time from the corn expression according to the code change information and the running status information. Generate a target delay task based on the target execution time, and push the target delay task into the first thread of the target pipeline for running.
[0084] In this embodiment, the corn expression includes 6 fields, and each field is a different time unit, including seconds, minutes, hours, days, months, and weeks. The producer-consumer model diagram is as Figure 7 shown. Each production terminal generates a delay task for the corresponding Jenkins pipeline, and each Jenkins pipeline can only store one delay task.
[0085] S206. Obtain the current execution time of the target delay task, and determine whether the current execution time is greater than or equal to a preset threshold. If so, based on the delay queue function, take out the target delay task from the delay queue, and push the target delay task into the second thread of the target pipeline for running.
[0086] Figure 3 This is the process of the management method for the Jenkins pipeline provided by the embodiment of the present application. Figure 3 , Figure 4 This is the process of the management method for the Jenkins pipeline provided by the embodiment of the present application. Figure 4 . As Figure 3 and Figure 4 shown, the management method for the Jenkins pipeline provided by this embodiment includes:
[0087] S301. In response to the save instruction of the target pipeline, generate a webhook for the target pipeline.
[0088] S302. Determine the corresponding target hosting platform and the corresponding branch code based on the target pipeline, and obtain the code information of the branch code according to the preset rules; determine whether the branch code has changed based on the code information; if so, send a call instruction for obtaining task information to the service interface of the target pipeline based on webhook;
[0089] S303. Receive the task information fed back by the service interface, and determine whether a delayed task has been pushed into the target pipeline based on the pollSCM function; if not, parse the target execution time from the corn expression based on the code change information and the running status information according to the delayed queue function; generate a target delayed task based on the target execution time; and push the target delayed task into the first thread of the target pipeline for running;
[0090] S304. Obtain the current execution time of the target delayed task, and determine whether the current execution time is greater than or equal to the preset threshold; if so, take out the target delayed task from the delayed queue based on the delayed queue function, and push the target delayed task into the second thread of the target pipeline for running.
[0091] A management method for Jenkins pipeline provided by this application responds to a save instruction of a target pipeline, and determines whether the pollSCM function of the target pipeline is started; if so, it determines whether a webhook has been generated for the target pipeline; if no webhook has been generated, it generates a webhook corresponding to the target pipeline; when the pollSCM function of the target pipeline is not started, it determines whether a webhook has been generated for the target pipeline; if a webhook has been generated, it clears the webhook corresponding to the target pipeline; determines a corresponding target hosting platform and corresponding branch code based on the target pipeline, and obtains code information of the branch code based on a preset rule; determines whether the branch code has changed based on the code information; if so, sends a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook; receives task information fed back by the service interface, and determines whether the task information meets a preset condition; where the task information includes code change information and the running status information of the target pipeline; determines whether a delay task has been pushed into the target pipeline based on the pollSCM function; if not, parses a target execution time from a corn expression based on the code change information and the running status information based on a delay queue function; generates a target delay task based on the target execution time, and pushes the target delay task into the first thread of the target pipeline for running; obtains the current execution time of the target delay task, and determines whether the current execution time is greater than or equal to a preset threshold; if so, takes out the target delay task from the delay queue based on the delay queue function, and pushes the target delay task into the second thread of the target pipeline for running, thereby enhancing the permission control of the pipeline, preventing backend technicians from running user pipelines, increasing data security, improving the stability of each deployment environment, and avoiding possible high-concurrency problems that affect the performance of Jenkins, achieving the technical effect of improving the security and management efficiency of Jenkins pipelines.
[0092] Figure 8 Structural schematic of a management device for a Jenkins pipeline provided by an embodiment of this application Figure 1 As Figure 8 shown, a management device 800 for a Jenkins pipeline provided by an embodiment of this application includes: a response module 801, a first processing module 802, and a second processing module 803;
[0093] The response module 801 processes the webhook of the target pipeline in response to a save instruction of the target pipeline.
[0094] The first processing module 802 determines the corresponding target hosting platform and the corresponding branch code based on the target pipeline, and obtains the code information of the branch code according to the preset rules; determines whether the branch code has changed based on the code information; if so, sends a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook.
[0095] The second processing module 803 receives the task information fed back by the service interface, and manages the target pipeline based on the task information.
[0096] In a possible implementation, the response module 801 is further configured to:
[0097] In response to the save instruction of the target pipeline, determine whether the pollSCM function of the target pipeline is started;
[0098] If so, determine whether the target pipeline has generated a webhook;
[0099] If the webhook has not been generated, generate the webhook corresponding to the target pipeline.
[0100] In a possible implementation, the response module 801 is further configured to:
[0101] When the pollSCM function of the target pipeline is not started, determine whether the target pipeline has generated a webhook;
[0102] If the webhook has been generated, clear the webhook corresponding to the target pipeline.
[0103] In a possible implementation, the second processing module 803 is further configured to:
[0104] Receive the task information fed back by the service interface, and determine whether the task information meets the preset conditions; wherein, the task information includes code change information and the running status information of the target pipeline;
[0105] If so, manage the target pipeline based on the code change information and the running status information according to the pollSCM function.
[0106] In a possible implementation, the second processing module 803 is further configured to:
[0107] Based on the pollSCM function, determine whether a delay task has been pushed into the target pipeline;
[0108] If not, generate a target delay task according to the code change information and the running status information, and push the target delay task into the first thread of the target pipeline for running.
[0109] In a possible implementation, the second processing module 803 is further configured to:
[0110] Based on the delay queue function, parse the target execution time from the corn expression according to the code change information and the running status information;
[0111] Generate a target delay task based on the target execution time.
[0112] In a possible implementation, the second processing module 803 is further configured to:
[0113] Obtain the current execution time of the target delay task, and determine whether the current execution time is greater than or equal to a preset threshold;
[0114] If so, based on the delay queue function, take out the target delay task from the delay queue, and push the target delay task into the second thread of the target pipeline for execution.
[0115] A management device for Jenkins pipelines provided by the present application, in response to a save instruction for a target pipeline, determines whether the pollSCM function of the target pipeline is started; if so, determines whether a webhook has been generated for the target pipeline; if no webhook has been generated, generates a webhook corresponding to the target pipeline; when the pollSCM function of the target pipeline is not started, determines whether a webhook has been generated for the target pipeline; if a webhook has been generated, clears the webhook corresponding to the target pipeline; determines a corresponding target hosting platform and corresponding branch code based on the target pipeline, and obtains code information of the branch code based on a preset rule; determines whether the branch code has changed based on the code information; if so, sends a call instruction for obtaining task information to a service interface of the target pipeline based on the webhook; receives task information fed back by the service interface, and determines whether the task information meets a preset condition; wherein the task information includes code change information and the running status information of the target pipeline; determines whether a delay task has been pushed into the target pipeline based on the pollSCM function; if not, parses a target execution time from a corn expression based on the code change information and the running status information based on a delay queue function; generates a target delay task based on the target execution time, and pushes the target delay task into a first thread of the target pipeline for running; obtains the current execution time of the target delay task, and determines whether the current execution time is greater than or equal to a preset threshold; if so, takes out the target delay task from the delay queue based on the delay queue function, and pushes the target delay task into a second thread of the target pipeline for running, thereby enhancing the permission control of the pipeline, preventing backend technicians from running user pipelines, increasing data security, improving the stability of each deployment environment, and avoiding possible high-concurrency problems that may affect the performance of Jenkins, achieving the technical effect of improving the security and management efficiency of Jenkins pipelines.
[0116] Figure 9 This is the hardware structure diagram of the management device for Jenkins pipelines provided by the embodiments of the present application. As Figure 9 shown, the management device 900 for Jenkins pipelines includes:
[0117] a processor 901, and a memory 902 communicatively connected to the processor;
[0118] The memory stores computer-executable instructions;
[0119] The processor executes the computer-executable instructions stored in the memory 902, so that the management device for Jenkins pipelines executes the Jenkins pipeline management method as described above.
[0120] It should be understood that the above-mentioned processor 901 may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly embodied as being executed and completed by a hardware processor, or can be executed and completed by a combination of hardware and software modules in the processor. The memory 902 may include a high-speed random access memory (RAM), and may also include non-volatile memory (NVM), such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disc, etc.
[0121] The embodiment of the present application correspondingly further provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the management method of the Jenkins pipeline as described above.
[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of the relevant data need to comply with relevant laws, regulations and standards, and corresponding operation entrances are provided for the user to select authorization or rejection.
[0123] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0124] It should be further noted that although the steps in the flowchart are sequentially shown according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this document, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.
[0125] It should be understood that the above device embodiments are merely illustrative, and the devices of the present application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0126] In addition, unless otherwise specified, in each embodiment of the present application, each functional unit / module can be integrated in one unit / module, or each unit / module can exist physically alone, or two or more units / modules can be integrated together. The above integrated unit / module can be implemented in the form of hardware or in the form of a software program module.
[0127] When the integrated unit / module is implemented in the form of hardware, the hardware can be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic storage medium or magneto-optical storage medium, such as resistive random access memory RRAM (Resistive Random Access Memory), dynamic random access memory DRAM (Dynamic Random Access Memory), static random access memory SRAM (Static Random-Access Memory), enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), high-bandwidth memory HBM (High-Bandwidth Memory), hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0128] When the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present application. And the aforementioned memory includes: various media that can store program codes, such as USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs.
[0129] In the above embodiments, the descriptions of each embodiment have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as within the scope described in this specification.
[0130] Those skilled in the art will readily think of other implementation schemes of the present application after considering the specification and practicing the invention disclosed herein. The present application aims to cover any variations, uses, or adaptive changes of the present application, and these variations, uses, or adaptive changes follow the general principles of the present application and include common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and the embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0131] It should be understood that the present application is not limited to the exact structure already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. A management method for Jenkins pipelines, characterized in that, including: processing the webhook of the target pipeline in response to a save instruction of the target pipeline; determining a corresponding target hosting platform and a corresponding branch code based on the target pipeline, and obtaining code information of the branch code based on a preset rule; judging whether the branch code has changed based on the code information; if so, sending a call instruction for obtaining task information to a service interface of the target pipeline based on the webhook; receiving the task information fed back by the service interface, and managing the target pipeline based on the task information.
2. The method according to claim 1, wherein The processing the webhook of the target pipeline in response to a save instruction of the target pipeline includes: judging whether the pollSCM function of the target pipeline is started in response to the save instruction of the target pipeline; if so, judging whether the webhook of the target pipeline has been generated; if the webhook has not been generated, generating the webhook corresponding to the target pipeline.
3. The method according to claim 2, wherein The method further includes: when the pollSCM function of the target pipeline is not started, judging whether the webhook of the target pipeline has been generated; if the webhook has been generated, clearing the webhook corresponding to the target pipeline.
4. The method according to claim 3, wherein The receiving the task information fed back by the service interface, and managing the target pipeline based on the task information includes: receiving the task information fed back by the service interface, and judging whether the task information meets a preset condition; wherein, the task information includes code change information and running status information of the target pipeline; if so, managing the target pipeline based on the pollSCM function according to the code change information and the running status information.
5. The method according to claim 4, characterized in that, The managing the target pipeline based on the pollSCM function according to the code change information and the running status information includes: judging whether a delay task has been pushed into the target pipeline based on the pollSCM function; if not, generating a target delay task according to the code change information and the running status information, and pushing the target delay task into a first thread of the target pipeline for running.
6. The method according to claim 5, wherein The generating a target delay task according to the code change information and the running status information includes: parsing a target execution time from a corn expression based on the delay queue function according to the code change information and the running status information; generating the target delay task based on the target execution time.
7. The method according to claim 6, wherein After pushing the target delay task into the target pipeline for running, it includes: obtaining a current execution time of the target delay task, and judging whether the current execution time is greater than or equal to a preset threshold; if so, taking out the target delay task from the delay queue based on the delay queue function, and pushing the target delay task into a second thread of the target pipeline for running.
8. A management device for a Jenkins pipeline, characterized in that, including: A response module that processes the webhook of the target pipeline in response to a save instruction of the target pipeline; A first processing module that determines a corresponding target hosting platform and corresponding branch code based on the target pipeline, and obtains code information of the branch code based on a preset rule; Determine whether the branch code has changed based on the code information; if so, send a call instruction for obtaining task information to the service interface of the target pipeline based on the webhook; A second processing module that receives the task information fed back by the service interface and manages the target pipeline based on the task information.
9. A management device for a Jenkins pipeline, characterized in that, Including: A processor and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement a method for managing a Jenkins pipeline according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the method for managing a Jenkins pipeline according to any one of claims 1 to 7.