A Jenkins pipeline configuration method, system and medium
By dragging and dropping nodes in the Jenkins pipeline configuration interface to create and adjust processes, the complexity of Jenkins pipeline configuration is solved, and an intuitive configuration method and efficient user experience are achieved.
Patent Information
- Application Number
- CN202211287067.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-20
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-10-20
AI Technical Summary
Jenkins pipeline configuration is complex, especially the declarative configuration is not intuitive, the parameter configuration is cumbersome, the technical threshold is high, and it is difficult for ordinary developers to master.
In the Jenkins pipeline configuration interface, you can create and adjust the main process, parallel sub-process, and serial sub-process by dragging nodes, and use the position array to update the index value to simplify the configuration process and lower the technical threshold.
It realizes the intuitive display of node execution relationship and sequence, simplifies the configuration method, lowers the technical threshold and improves usage efficiency.
Smart Images

Figure CN115495173B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a Jenkins pipeline configuration method, system and medium. Background Art
[0002] Jenkins is an open-source CI&CD software that automates various tasks, including software building, testing, and deployment. Jenkins also supports various run modes, including running on system packages, Docker, or Java programs.
[0003] Jenkins Pipeline is a set of plugins that supports the implementation and integration of continuous delivery pipelines into Jenkins. A continuous delivery (CD) pipeline is an automated expression of the process used to get software from version control to users and customers. Every software change undergoes a complex journey on its way to release, including building the software in a reliable and repeatable manner, and passing it through multiple testing and deployment stages.
[0004] The definition of the Jenkins pipeline is written in a text file, Jenkinsfile, which can be submitted to the project's source code control repository, treating the CD pipeline as part of the application and versioning and reviewing it like other code.
[0005] Jenkinsfiles are primarily written using two syntaxes: declarative and scripted. Declarative syntax is less intuitive, with each node listed linearly, making it difficult to understand their execution relationships and order. Parameter configuration is also complex, requiring numerous and detailed parameters for each node, increasing configuration difficulty. Scripted syntax requires learning the Jenkins scripting language separately, which is generally beyond the skill set of the average developer. It also suffers from the numerous configuration items and complexity. Summary of the Invention
[0006] In response to the deficiencies in the prior art, the present invention provides a Jenkins pipeline configuration method, system, and medium to lower the technical threshold for Jenkins configuration, simplify configuration, and improve usage efficiency.
[0007] First, a Jenkins pipeline configuration method includes:
[0008] Create a main process in the Jenkins pipeline configuration interface; the main process includes a start node, an end node, and at least one first dimension node, where the start node, the first dimension node, and the end node are executed serially;
[0009] Drag the first dimension nodes to adjust the order of the first dimension nodes in the main process.
[0010] Furthermore, after creating the main process, it also includes:
[0011] In the Jenkins pipeline configuration interface, create a parallel sub-process for the first dimension node; the parallel sub-process includes at least one second dimension node; each first dimension node and all the second dimension nodes created by it are executed in parallel;
[0012] Drag the second dimension node to adjust the order of the second dimension node in the parallel sub-process to which it belongs, or drag the second dimension node to the main process to convert the second dimension node into a first dimension node.
[0013] Furthermore, after creating the main process, it also includes:
[0014] In the Jenkins pipeline configuration interface, create a serial sub-process for the first dimension node or the second dimension node. The serial sub-process includes at least one third dimension node, and all third dimension nodes under each first dimension node or second dimension node are executed serially.
[0015] Drag the third dimension node to adjust the order of the third dimension node in the serial sub-process to which it belongs, or drag the third dimension node to another serial sub-process.
[0016] Furthermore, after creating the main process, it also includes:
[0017] Drag the first dimension node and drop it into the parallel sub-process or serial sub-process.
[0018] Furthermore, the positions of the first dimension node, the second dimension node, and the third dimension node after dragging are obtained by the following method:
[0019] Set a position array for each first-dimension node, second-dimension node, and third-dimension node; the initial value of the position array is empty;
[0020] Get the index value of the created first-dimension node, second-dimension node, or third-dimension node, and update the corresponding position array according to the index value;
[0021] When dragging a first-dimension node, a second-dimension node, or a third-dimension node, the corresponding position array is updated according to the index value before dragging and the dimension position of the minimum dimension after dragging.
[0022] Furthermore, updating the corresponding position array according to the index value before dragging and the dimension position of the minimum dimension after dragging specifically includes:
[0023] Get the index value of the first dimension node, the second dimension node, or the third dimension node before dragging, and extract the dimension position of the smallest dimension in the index value;
[0024] Get the minimum dimension position of the first dimension node, the second dimension node, or the third dimension node after dragging;
[0025] When dragging a non-current column, obtain the column position after dragging, and obtain the index value after dragging based on the column position after dragging and the dimension position of the minimum dimension; delete the data corresponding to the column position in the index value before dragging;
[0026] When dragging the current column, the dimension position in the index value before dragging is replaced with the dimension position of the minimum dimension after dragging to obtain the index value of the minimum dimension after dragging;
[0027] Update the position array according to the index value after dragging.
[0028] In a second aspect, a Jenkins pipeline configuration system includes a processor, an input device, an output device, and a memory, wherein the processor, the input device, the output device, and the memory are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the first aspect.
[0029] In a third aspect, a computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the method of the first aspect.
[0030] As can be seen from the above technical solution, the Jenkins pipeline configuration method, system, and medium provided by the present invention can directly drag and drop first-dimensional nodes in the Jenkins pipeline configuration interface to create and adjust the main process. Users can intuitively see the execution relationship and execution order of each node, simplifying the configuration method, reducing configuration difficulty, and improving usage efficiency. In addition, this method does not require users to learn the Jenkins scripting language, lowering the technical threshold for Jenkins configuration. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly describes the drawings required for the specific embodiments or the description of the prior art. Similar elements or parts are generally identified by similar reference numerals throughout the drawings. Elements or parts in the drawings are not necessarily drawn to scale.
[0032] Figure 1 A schematic diagram of a configured Jenkins pipeline provided for the embodiment.
[0033] Figure 2 This is a flowchart of the dragging method provided in the embodiment.
[0034] Figure 3 This is a flowchart of a method for obtaining index values after dragging provided in an embodiment.
[0035] Figure 4 A schematic diagram of dragging a non-current column provided in an embodiment.
[0036] Figure 5 A schematic diagram of dragging the current column provided in an embodiment.
[0037] Figure 6 A module diagram of a system provided in an embodiment. DETAILED DESCRIPTION
[0038] The following embodiments of the technical solution of the present invention are described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention and are therefore only examples and are not intended to limit the scope of protection of the present invention. It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by those skilled in the art to which the present invention belongs.
[0039] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0040] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0041] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0042] Example:
[0043] A Jenkins pipeline configuration method, including:
[0044] Create a main process in the Jenkins pipeline configuration interface; the main process includes a start node, an end node, and at least one first dimension node, where the start node, the first dimension node, and the end node are executed serially;
[0045] Drag the first dimension nodes to adjust the order of the first dimension nodes in the main process.
[0046] In this embodiment, the Jenkins pipeline configuration interface can be a visual interface in the code development software. For example, the Jenkins pipeline configuration interface can implement the function of configuring the Jenkins pipeline through css styles and js configuration parameters. Figure 1 The main process in the pipeline consists of one start node, three first-dimension nodes, and one end node. The three first-dimension nodes are named Pull Code, Compile, and Release. The start node, pull code node, compile node, release node, and end node are connected in series. The execution order of these nodes is consistent with the order in which they are connected. That is, each node is executed in series according to the connection relationship. The number and execution order of the first-dimension nodes can be increased, decreased, or adjusted according to the actual needs of the pipeline.
[0047] In this embodiment, the Jenkins pipeline configuration method can also adjust the order of the first dimension nodes in the main process according to actual needs during the configuration process. The adjustment method is to drag the first dimension node, for example, drag the compilation node in the main process to the release node, so that the execution order of the main process is to execute the release node first and then the compilation node.
[0048] This Jenkins pipeline configuration method allows users to create and adjust the main process by dragging and dropping nodes directly in the Jenkins pipeline configuration interface. Users can intuitively see the execution relationships and order of each node, simplifying the configuration process, reducing configuration difficulty, and improving efficiency. Furthermore, this method does not require users to learn the Jenkins scripting language, lowering the technical threshold for Jenkins configuration.
[0049] Furthermore, in some embodiments, after the main process is created, the following steps are further included:
[0050] In the Jenkins pipeline configuration interface, create a parallel sub-process for the first dimension node; the parallel sub-process includes at least one second dimension node; each first dimension node and all the second dimension nodes created by it are executed in parallel;
[0051] Drag the second dimension node to adjust the order of the second dimension node in the parallel sub-process to which it belongs, or drag the second dimension node to the main process to convert the second dimension node into a first dimension node.
[0052] In this embodiment, the method can also add parallel sub-processes under the first dimension node. Figure 1 Under the pull code node, set up two second-dimension nodes for parallel execution: a sleep node and a print node. These nodes are connected in parallel, meaning the Jenkins pipeline can simultaneously execute code pull, sleep, and print operations. The number of second-dimension nodes can be increased or decreased based on the actual needs of the pipeline.
[0053] In this embodiment, the Jenkins pipeline configuration method can also adjust the position of the second-dimension node according to actual needs during the configuration process. The adjustment method is to drag the second-dimension node. For example, the dormant node can be dragged after the print node, or it can be dragged between the compile node and the release node in the main process. This can achieve the node dimension upgrade function. The execution order of the main process is: compile -> dormant -> release.
[0054] Furthermore, in some embodiments, after the main process is created, the following steps are further included:
[0055] In the Jenkins pipeline configuration interface, create a serial sub-process for the first dimension node or the second dimension node. The serial sub-process includes at least one third dimension node, and all third dimension nodes under each first dimension node or second dimension node are executed serially.
[0056] Drag the third dimension node to adjust the order of the third dimension node in the serial sub-process to which it belongs, or drag the third dimension node to another serial sub-process.
[0057] In this embodiment, the method can also add a serial sub-process under the first dimension node or the second dimension node. Figure 1 In the code pull node (first dimension node), two third-dimensional nodes are set up for serial execution, namely the checkout node from the code repository and the sleep node. One third-dimensional node is also set up in the sleep node (second dimension node), which is the sleep node. All third-dimensional nodes under the first-dimensional node or the second-dimensional node are executed serially. For example, the execution order of the third-dimensional nodes under the code pull node is: checkout from the code repository->sleep, and the execution order of the third-dimensional nodes under the sleep node is: sleep node. The execution order of the third-dimensional nodes is consistent with the connection order, that is, the third-dimensional nodes are executed serially in sequence according to the connection relationship. The number and execution order of the third-dimensional nodes can be increased, decreased, and adjusted according to the actual needs of the pipeline.
[0058] In this embodiment, the Jenkins pipeline configuration method can also adjust the position of the third dimension node according to actual needs during the configuration process, wherein the adjustment method is to drag the third dimension node. Since the third dimension node is the smallest node, it does not have the dimension upgrade function. The third dimension node can only be dragged to adjust the order in the serial sub-process to which it belongs or dragged to other serial sub-processes. For example, the node checked out from the code repository can be dragged after the sleep node, so that the execution order of the third dimension node under the code node is: sleep -> check out from the code repository. The node checked out from the code repository can also be dragged to the parallel sub-process under the sleep node, for example, dragged before the sleep node, so that the execution order of the third dimension node under the sleep node is: check out from the code repository -> sleep.
[0059] Furthermore, in some embodiments, after the main process is created, the following steps are further included:
[0060] Drag the first dimension node and drop it into the parallel sub-process or serial sub-process.
[0061] In this embodiment, since the first-dimensional node is the largest node, the method also supports the function of reducing the dimensionality of the first-dimensional node. That is, the method can drag the first-dimensional node to a parallel sub-process or a serial sub-process to become a second-dimensional node or a third-dimensional node. For example, the Compile node can be dragged into the parallel sub-process under the Pull Code node, such as dragging it between the From Sleep node and the Print node. Alternatively, it can be dragged into the serial sub-process under the Sleep node, such as dragging it before the From Sleep node, so that the execution order of the third-dimensional nodes under the Sleep node is: Compile -> Sleep.
[0062] Further, in some embodiments, see Figure 2 The positions of the first-dimension node, the second-dimension node, and the third-dimension node after dragging are obtained by the following method:
[0063] S1: Set the position array for each first-dimension node, second-dimension node, and third-dimension node; the initial value of the position array is empty;
[0064] S2: Get the index value of the created first-dimension node, second-dimension node, or third-dimension node, and update the corresponding position array according to the index value;
[0065] S3: When dragging a first-dimension node, a second-dimension node, or a third-dimension node, the corresponding position array is updated according to the index value before dragging and the dimension position of the minimum dimension after dragging.
[0066] In this embodiment, since the start and end nodes cannot be dragged, there is no need to set position arrays for the start and end nodes. The initial values of the position arrays for the first, second, and third dimension nodes are all empty. Since this method involves nodes in three dimensions, the position array can be a three-element array, representing the position of the node in each dimension. After the node is created, the position array is updated based on the node's position in each dimension.
[0067] In this embodiment, the method can use the VueDraggable drag component to complete the dragging of nodes. However, after completing the dragging, the VueDraggable drag component can only locate the dimensional position under the smallest dimension. For example, the position array of the sleep node in the third dimension under the pull code node is defined as [0,0,2], where the first 0 is the dimensional position of the sleep node in the first dimension, the second 0 is the dimensional position of the sleep node in the second dimension, and 2 is the dimensional data of the sleep node in the third dimension. Assuming that the sleep node is dragged to the third dimension under the compile node (after dragging it to the Maven build), then after the dragging is completed, the position array of the sleep node should be updated to [1,0,1], indicating that the sleep node is dragged to the second node in the third dimension under the second node in the first dimension. However, the VueDraggable drag component only displays the dimensional position change of the lowest dimension, that is, only displays 2->1. Therefore, if this method needs to obtain the position of each dimension in the complete position data, it is necessary to loop through three layers of DOM containers in the VueDraggable drag component, obtain the dimensional position under each dimension, and assign the dimensional position to the position array.
[0068] In this embodiment, if it is necessary to traverse three times each time to complete the update of the position array, it will occupy more computer resources. Therefore, after completing the dragging, this method determines whether it belongs to the current column drag or the non-current column drag based on the index value before dragging and the dimensional position after dragging, thereby updating the corresponding position array and reducing the occupied computer resources.
[0069] Further, in some embodiments, see Figure 3 , according to the index value before dragging and the dimension position of the minimum dimension after dragging, the corresponding position array is updated specifically including:
[0070] S11: Obtain the index value of the first dimension node, the second dimension node, or the third dimension node before dragging, and extract the dimension position of the minimum dimension in the index value;
[0071] S12: Obtaining the minimum dimension position of the first dimension node, the second dimension node, or the third dimension node after dragging;
[0072] S13: When the drag is not for the current column, the column position after the drag is obtained, and the index value after the drag is obtained according to the column position after the drag and the dimension position of the minimum dimension; the data corresponding to the column position in the index value before the drag is deleted;
[0073] S14: When the drag is a current column drag, the dimension position of the minimum dimension in the index value before the drag is replaced with the dimension position of the minimum dimension after the drag to obtain the index value after the drag;
[0074] S15: Update the position array according to the index value after dragging.
[0075] In this embodiment, the index value of the node before dragging includes the dimensional position of the node in each dimension. The column position includes the dimensional position of the first dimension and / or the second dimension. For example, if the index value of the node is [0, 0, 2], then the column position is [0, 0]; if the index value is [1, 0], then the column position is [1].
[0076] In this embodiment, the method first records the index value before dragging when dragging a node, and determines whether it is a current column drag based on the position after dragging. If it is a non-current column drag, see Figure 4 , assuming that the 2-1 node is dragged to the 1-3 node, the position array of the 2-1 node is [1,0], and the position array of the 1-3 node is [0,2]. When the drag is completed, the vuedraggable drag component can be used to obtain the dimension position of the smallest dimension after the drag, which is 2. This method can also use the evt.pullMode function of the vuedraggable drag component to determine whether the position before and after the drag belongs to the same column, thereby determining Figure 4 The drag is not part of the same column. In this case, the evt.to function of the vuedraggable drag component is used to obtain the index value [0, 2] after the drag is completed. Since the data at the original location is invalid after the drag is completed, the data in the column where the original 2-1 node is located needs to be deleted, including the data in the second and third dimension arrays under the 2-1 node.
[0077] In this embodiment, if the current column is dragged, see Figure 5 , assuming that the 1-1 node is dragged to the 1-3 node, the position array of the 1-1 node is [0,0], and the position array of the 1-3 node is [0,2]. After the drag is completed, the vuedraggable drag component can be used to obtain the dimension position of the smallest dimension after the drag, which is 2. This method can also use the evt.pullMode function of the vuedraggable drag component to determine whether the position before and after the drag belongs to the same column, thereby determining whether the position before and after the drag belongs to the same column. Figure 5The drag belongs to the same column drag, and the dimension position 2 of the smallest dimension after the drag replaces the dimension position 0 of the smallest dimension in the index value before the drag.
[0078] A Jenkins pipeline configuration system, see Figure 6 , including a processor 10, an input device 20, an output device 30 and a memory 40. The processor 10, the input device 20, the output device 30 and the memory 40 are connected to each other, wherein the memory 40 is used to store a computer program, the computer program includes program instructions, and the processor 10 is configured to call the program instructions to execute the above method.
[0079] It should be understood that in the embodiment of the present invention, the processor 10 may be a central processing unit (CPU), and the processor 10 may also be other general-purpose processors 10, digital signal processors 10 (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor 10 may be a microprocessor 10 or any conventional processor 10, etc.
[0080] The input device 20 may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc. The output device 30 may include a display (LCD, etc.), a speaker, etc.
[0081] The memory 40 may include a read-only memory 40 and a random access memory 40, and provides instructions and data to the processor 10. A portion of the memory 40 may also include a nonvolatile random access memory 40. For example, the memory 40 may also store information on the device type.
[0082] The system provided in the embodiment of the present invention is briefly described. For matters not mentioned in the embodiment part, reference may be made to the corresponding content in the aforementioned embodiment.
[0083] A computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the above method.
[0084] The computer-readable storage medium may be an internal storage unit of the terminal described in any of the aforementioned embodiments, such as a hard disk or memory of the terminal. The computer-readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the terminal and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the terminal. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0085] The medium provided in the embodiments of the present invention is briefly described. For matters not mentioned in the embodiment part, reference may be made to the corresponding contents in the aforementioned embodiments.
[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and description of the present invention.
Claims
1. A Jenkins pipeline configuration method, characterized in that: include: Create a main process in the Jenkins pipeline configuration interface; the main process includes a start node, an end node, and at least one first dimension node, wherein the start node, the first dimension node, and the end node are executed serially; Drag the first dimension node to adjust the order of the first dimension nodes in the main process; After creating the main process, it also includes: In the Jenkins pipeline configuration interface, a parallel sub-process is created for the first dimension node; the parallel sub-process includes at least one second dimension node; each first dimension node and all the second dimension nodes created by it are executed in parallel; Drag the second dimension node to adjust the order of the second dimension node in the corresponding parallel sub-process, or drag the second dimension node into the main process to convert the second dimension node into the first dimension node; In the Jenkins pipeline configuration interface, a serial sub-process is created for the first dimension node or the second dimension node; the serial sub-process includes at least one third dimension node, and all the third dimension nodes under each first dimension node or the second dimension node are executed serially; Drag the third dimension node to adjust the order of the third dimension node in the serial sub-process to which it belongs, or drag the third dimension node to another serial sub-process; Drag the first dimension node and drag the first dimension node into the parallel sub-process or the serial sub-process; The positions of the first dimension node, the second dimension node, and the third dimension node after dragging are obtained by the following method: Setting a position array for each of the first-dimension node, the second-dimension node, and the third-dimension node; an initial value of the position array is empty; Obtaining the index value of the created first-dimension node, the second-dimension node, or the third-dimension node, and updating the corresponding position array according to the index value; When dragging the first dimension node, the second dimension node, or the third dimension node, updating the corresponding position array according to the index value before dragging and the dimension position of the minimum dimension after dragging; The updating of the corresponding position array according to the index value before dragging and the dimension position of the minimum dimension after dragging specifically includes: Obtain the index value of the first dimension node, the second dimension node, or the third dimension node before dragging, and extract the dimension position of the minimum dimension in the index value; Obtaining the minimum dimension position of the first dimension node, the second dimension node, or the third dimension node after dragging; When the drag is not a drag of the current column, the column position after the drag is obtained, and the index value after the drag is obtained according to the column position after the drag and the dimension position of the minimum dimension; the data corresponding to the column position in the index value before the drag is deleted; When the drag is a current column drag, replacing the dimension position of the minimum dimension in the index value before the drag with the dimension position of the minimum dimension after the drag to obtain the index value after the drag; Update the position array according to the index value after dragging.
2. A Jenkins pipeline configuration system, characterized in that: The method comprises a processor, an input device, an output device and a memory, wherein the processor, the input device, the output device and the memory are connected to each other, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to claim 1.
3. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program including program instructions, which, when executed by a processor, cause the processor to perform the method according to claim 1 .
Citation Information
Patent Citations
Method and device for realizing visual process configuration through dragging
CN110377209A