Assembly line construction method and device supporting multiple technology stacks and electronic equipment
Through the pipeline construction method that supports multi-tech stacks, execution scripts suitable for different technology stacks are parsed and generated, and executed in the corresponding construction environment, the shortcomings of the Jenkins pipeline system in multi-tech stack support and high concurrent execution are solved, and an efficient and stable automated construction process is achieved.
Patent Information
- Application Number
- CN202411833922.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing Jenkins-based pipeline system performs poorly in multi-tech stack support and high concurrency execution, resulting in poor technology stack compatibility, insufficient scalability and concurrency, insufficient plug-in maintenance and poor stability.
Provide a pipeline construction method that supports multi-tech stacks. By analyzing the technology stack information in pipeline task requests, determining the target technology stack type, and calling the corresponding pipeline parser to generate an execution script, which is sent to the matching construction environment for execution.
It realizes an efficient and stable automated construction process across the technology stack, lowers technical thresholds, improves system compatibility and expansion capabilities, and reduces operational complexity and operation and maintenance costs.
Smart Images

Figure CN119806646A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of automated construction technology, and in particular to a pipeline construction method, device, and electronic device supporting multiple technology stacks. Background Art
[0002] In the modern software development process, continuous integration and continuous delivery (CI / CD) have become an important means to achieve rapid iteration, improve code quality and delivery efficiency. CI / CD processes usually rely on automated build, test and deployment pipelines to complete various tasks. In practical applications, Jenkins is the most commonly used CI / CD tool, and many companies build and manage pipeline tasks based on the Jenkins platform. However, Jenkins itself also has some limitations, which makes it less than ideal in terms of multi-technology stack support and high concurrent execution.
[0003] The existing Jenkins-based pipeline system technology stack has poor compatibility. Jenkins' pipeline scripts mainly use specific syntax (such as Groovy) and cannot directly support other commonly used scripting languages. At the same time, they lack scalability and concurrency. Although Jenkins provides a large number of plug-ins, many plug-ins are poorly maintained, have poor stability, and have low concurrent execution efficiency, resulting in high system resource usage and low operating efficiency when processing complex, multi-tasking pipelines. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a pipeline construction method, device and electronic device that supports multiple technology stacks, which can enable users to freely select technology stacks when creating pipelines, automatically generate corresponding execution scripts, and send tasks to the corresponding construction environment for execution, thereby realizing an efficient and stable automated construction process across technology stacks.
[0005] The present disclosure provides a pipeline construction method supporting multiple technology stacks, including:
[0006] In response to a pipeline task request, parsing technology stack information indicated in the pipeline task request, and determining a target technology stack type corresponding to the technology stack information;
[0007] Calling a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type;
[0008] The pipeline execution script is sent to a build environment matching the target technology stack type for execution.
[0009] In an optional implementation, parsing the technology stack information indicated in the pipeline task request and determining the target technology stack type corresponding to the technology stack information specifically includes:
[0010] Creating a technology stack map that defines multiple technology stack types, wherein each technology stack type and a corresponding technology stack number are stored in the technology stack map through a key-value pair;
[0011] According to the received task request identifier corresponding to the pipeline task request, query the technology stack information described in the form of the technology stack number, and check whether the corresponding technology stack number exists in the technology stack mapping;
[0012] If so, the target technology stack type is determined according to the technology stack number and the mapping relationship stored in the technology stack mapping.
[0013] In an optional implementation, calling a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type specifically includes:
[0014] Calling a preset pipeline parser corresponding to the target technology stack type to parse the task parameter information set by the user for the pipeline task;
[0015] A script generation template corresponding to the target technology stack type is selected, and the task parameter information is embedded into the corresponding variables in the script generation template to generate the pipeline execution script.
[0016] In an optional implementation, the target technology stack type includes at least one of a Jenkins technology stack, a Shell technology stack, an Ansible technology stack, and a Python technology stack;
[0017] For each type of the target technology stack, call the corresponding script generation method and pass in the task parameter object carrying the task parameter information;
[0018] In the script generation method, the task parameter information carried in the task parameter object is read, and the task parameter information at least includes stage information and a command list;
[0019] By executing the script generation method, the pipeline execution script in the format corresponding to the target technology stack type is generated using the syntax specification corresponding to the target technology stack type;
[0020] Among them, the script generation method corresponding to the Jenkins technology stack is the getPipelineScript method, the script generation method corresponding to the Shell technology stack is the getShellScript method, the script generation method corresponding to the Ansible technology stack is the getANSBScript method, and the script generation method corresponding to the Python technology stack is the getPYTNScript method.
[0021] In an optional implementation, sending the pipeline execution script to a build environment matching the target technology stack type for execution specifically includes:
[0022] Determining a target build environment that matches the target technology stack type;
[0023] Creating an HTTP request encapsulating the pipeline execution script, and setting a corresponding request timeout for the HTTP request;
[0024] The HTTP request is executed to send the pipeline execution script to the construction environment, and script execution response information returned by the construction environment is received.
[0025] In an optional implementation manner, after receiving the script execution response information returned by the construction environment, the method further includes:
[0026] Parsing the request result included in the script execution response information, and when determining that the request result is a request failure, recording an error log and sending a process request failure information to the user;
[0027] When it is determined that the request result is a successful request, the response result included in the script execution response information is parsed; if it is determined that the response result is a failed response, an error log is recorded and process execution failure information is sent to the user.
[0028] In an optional implementation, creating an HTTP request encapsulating the pipeline execution script specifically includes:
[0029] Determine the target API path corresponding to the build environment;
[0030] Use the HttpPost object to package the pipeline execution script into a POST request;
[0031] The JSON data containing the pipeline execution script is encapsulated into the request body through the setEntity method.
[0032] The present disclosure also provides a pipeline construction device supporting multiple technology stacks, including:
[0033] A technology stack type determination module, configured to, in response to a pipeline task request, parse the technology stack information indicated in the pipeline task request and determine a target technology stack type corresponding to the technology stack information;
[0034] An execution script generation module is used to call a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type;
[0035] The script execution module is used to send the pipeline execution script to a construction environment matching the target technology stack type for execution.
[0036] An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the above-mentioned pipeline construction method supporting multiple technology stacks, or steps in any possible implementation of the above-mentioned pipeline construction method supporting multiple technology stacks are performed.
[0037] An embodiment of the present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program executes the above-mentioned pipeline construction method supporting multiple technology stacks, or the steps of any possible implementation of the above-mentioned pipeline construction method supporting multiple technology stacks.
[0038] The embodiments of the present disclosure also provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the above-mentioned pipeline construction method supporting multiple technology stacks, or the steps in any possible implementation of the above-mentioned pipeline construction method supporting multiple technology stacks.
[0039] The disclosed embodiment provides a pipeline construction method, device and electronic device supporting multiple technology stacks. In response to a pipeline task request, the technology stack information indicated in the pipeline task request is parsed, and the target technology stack type corresponding to the technology stack information is determined; the preset pipeline parser corresponding to the target technology stack type is called to generate a pipeline execution script suitable for the target technology stack type; the pipeline execution script is sent to a construction environment matching the target technology stack type for execution. This allows users to freely select a technology stack when creating a pipeline, automatically generate a corresponding execution script, and send the task to the corresponding construction environment for execution, thereby achieving an efficient and stable automated construction process across technology stacks.
[0040] The disclosed embodiment provides a multi-technology stack automatic adaptation and parsing mechanism, supports the parsing of multiple technology stacks such as Jenkins, Shell, Ansible, Python, etc., and users do not need to manually write scripts for different technology stacks. The system automatically generates corresponding scripts according to the technology stack type, which reduces the technical threshold and realizes the support of multiple technology stacks by the same system. There is no need to integrate additional plug-ins or modify system configuration, which significantly improves the compatibility and expansion capabilities of the system. At the same time, it provides a task scheduling and execution mechanism based on the build environment, which automatically matches the corresponding build environment according to the parsed target technology stack type. Without user intervention, the system automatically distributes tasks to the matching build environment for execution, reducing the complexity of operations. The build tasks are distributed to the most suitable environment for operation, reducing execution failures or exceptions caused by environment mismatch, and improving the stability and execution efficiency of the build process. It also provides modular script generation and dynamic expansion capabilities. The script generation logic of each technology stack is modularized to achieve independent parsing, generation and execution. When adding a new technology stack, you only need to add the corresponding script generation module without modifying the core logic. The modular design facilitates system maintenance and expansion. Users can easily add new technology stack support, which improves the flexibility and reusability of the system. Through templated script generation, it reduces repetitive development and maintenance work, and reduces the operation and maintenance costs of managing multiple technology stacks.
[0041] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0043] Figure 1 A flowchart of a pipeline construction method supporting multiple technology stacks provided by an embodiment of the present disclosure is shown;
[0044] Figure 2 A flow chart showing a method for determining a target technology stack provided by an embodiment of the present disclosure is shown;
[0045] Figure 3 A flowchart of a method for generating a pipeline execution script provided by an embodiment of the present disclosure is shown;
[0046] Figure 4 A flowchart of a method for executing a pipeline execution script provided by an embodiment of the present disclosure is shown;
[0047] Figure 5 A schematic diagram of a pipeline construction device supporting multiple technology stacks provided by an embodiment of the present disclosure is shown;
[0048] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0050] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0051] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0052] Research has found that the existing Jenkins-based pipeline system technology stack has poor compatibility. Jenkins' pipeline scripts mainly use specific syntax (such as Groovy) and cannot directly support other commonly used scripting languages. At the same time, they lack scalability and concurrency. Although Jenkins provides a large number of plug-ins, many plug-ins are poorly maintained, have poor stability, and have low concurrent execution efficiency, resulting in high system resource usage and low operating efficiency when processing complex, multi-tasking pipelines.
[0053] Based on the above research, the present disclosure provides a pipeline construction method, device and electronic device that supports multiple technology stacks. In response to a pipeline task request, the technology stack information indicated in the pipeline task request is parsed, and the target technology stack type corresponding to the technology stack information is determined; the preset pipeline parser corresponding to the target technology stack type is called to generate a pipeline execution script suitable for the target technology stack type; the pipeline execution script is sent to a construction environment that matches the target technology stack type for execution. This allows users to freely select a technology stack when creating a pipeline, automatically generate a corresponding execution script, and send the task to the corresponding construction environment for execution, thereby achieving an efficient and stable automated construction process across technology stacks.
[0054] To facilitate understanding of this embodiment, a pipeline construction method supporting multiple technology stacks disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the pipeline construction method supporting multiple technology stacks provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the pipeline construction method supporting multiple technology stacks can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0055] See also Figure 1 As shown, it is a flowchart of a pipeline construction method supporting multiple technology stacks provided by an embodiment of the present disclosure, the method includes steps S101 to S103, wherein:
[0056] S101. In response to a pipeline task request, parse the technology stack information indicated in the pipeline task request, and determine a target technology stack type corresponding to the technology stack information.
[0057] In a specific implementation, the pipeline information configured by the user through a visual interface is received, and in response to the pipeline task request triggered by the user, the pipeline task request is parsed to obtain the type of technology stack selected by the user. The supported technology stack types include at least one of the Jenkins technology stack (PIPL), Shell technology stack (SHLL), Ansible technology stack (ANSB) and Python technology stack (PYTN).
[0058] For details, see Figure 2FIG. 1 is a flowchart of a method for determining a target technology stack provided by an embodiment of the present disclosure, the method comprising steps S1011 to S1013, wherein:
[0059] S1011. Create a technology stack map that defines multiple technology stack types, and store each technology stack type and the corresponding technology stack number in the technology stack map through a key-value pair.
[0060] S1012: According to the received task request identifier corresponding to the pipeline task request, query the technology stack information described in the form of technology stack number, and check whether the corresponding technology stack number exists in the technology stack mapping.
[0061] S1013: If it exists, determine the target technology stack type according to the technology stack number and the mapping relationship stored in the technology stack mapping.
[0062] In the specific implementation, first create a HashMap named stackMap as a technology stack mapping to store the mapping relationship of multiple technology stacks. The key of stackMap is the number of the technology stack (such as "01", "02", etc.), and the value is the name of the technology stack (such as "PIPL", "SHLL", "ANSB", "PYTN"). Through stackMap.put("01", "PIPL") and other methods, multiple technology stack types (such as PIPL, Shell, Ansible, Python) are added to stackMap to define the technology stack types supported by the system, providing users with multiple choices.
[0063] Here, through the queryJobInfoById(id) method, the basic information of the job is queried according to the task request identifier (id) corresponding to the incoming pipeline task request to obtain the technology stack information described in the form of the technology stack number, and the result is stored in the OV object, and the target technology stack selected by the user in the OV object is checked to see if it is in the list of supported technology stacks. If it exists, the technology stack type of the OV object is set, and the technology stack information described in the form of the technology stack number is mapped to the corresponding technology stack name.
[0064] For example, the technology stack information "01" described in the form of a technology stack number is converted into the corresponding technology stack name "PIPL".
[0065] As a possible implementation, create a ResultMap object resultMap to store the returned results. Put the queried OV object storing the technology stack information as data into resultMap. Use the LinkedHashMap object titleMap to define the title or label of the data, and set the pipINo (number), name (name), label (label), techStackType (technology stack type) and other information in turn.
[0066] In this way, multiple technology stack types can be mapped through technology stack mapping, allowing users to select a suitable technology stack when creating a pipeline and associate the technology stack type with a specific job, thus achieving multi-technology stack compatibility of the system.
[0067] S102: calling a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type.
[0068] In the specific implementation, each technology stack type corresponds to different pipeline script generation logic. The corresponding pipeline parser is called according to the target technology stack type selected by the user. Each technology stack type has a dedicated parser that contains proprietary script generation logic for that type of technology stack.
[0069] Specifically, for each target technology stack type, the corresponding script generation method is called and the task parameter object carrying the task parameter information is passed in; in the script generation method, the task parameter information carried in the task parameter object is read, and the task parameter information includes at least stage information and a command list; by executing the script generation method, the grammatical specification corresponding to the target technology stack type is used to generate a pipeline execution script in a format corresponding to the target technology stack type; among them, the script generation method corresponding to the Jenkins technology stack is the getPipelineScript method, the script generation method corresponding to the Shell technology stack is the getShellScript method, the script generation method corresponding to the Ansible technology stack is the getANSBScript method, and the script generation method corresponding to the Python technology stack is the getPYTNScript method.
[0070] Here, for the Jenkins technology stack, the system will call the Jenkins pipeline parser, which will generate the Jenkins Pipeline script based on the task parameters. If a pure Shell script is selected, the system will call the Shell parser to generate a Shell script to ensure that the script is suitable for the Shell environment. For the Ansible technology stack, the system will call the Ansible parser to generate an Ansible Playbook or task script for configuring and managing the environment. Python technology stack: When Python is selected, the system calls the Python parser to generate a script adapted to the Python environment.
[0071] Among them, for the Jenkins technology stack, call the getPipelineScript method to generate a pipeline execution script in Jenkins format; for the Shell technology stack, call the getShellScript method to generate a pipeline execution script in Shell format; for the Ansible technology stack, call the getANSBScript method to generate a pipeline execution script in Ansible format; for the Python technology stack, call the getPYTNScript method to generate a pipeline execution script in Python format.
[0072] Here, the getPipelineScript method is called for the Jenkins technology stack to generate a pipeline execution script in Jenkins format. The input of the getPipelineScript method is the task parameter information configured by the user, which at least includes stage information, build commands, environment variables, etc. The getPipelineScript method is called and the task parameter object (such as taskConfig) is passed in. In the getPipelineScript method, the stage information, step commands, etc. in taskConfig are read, and the script is generated using the Groovy template according to the syntax specification of the Jenkins pipeline.
[0073] Here, the getShellScript method is called for the Shell technology stack to generate a pipeline execution script in Shell format. The input of the getShellScript method is the task parameter information configured by the user, which at least includes the executed Shell command, environment variables, etc. The getShellScript method is called and the task parameter object (such as taskConfig) is passed in. The stage information, command list, etc. in taskConfig are read in the getShellScript method, and the script is generated using the Shell language format.
[0074] Here, the getANSBScript method is called for the Ansible technology stack to generate a pipeline execution script in Ansible format. The input of the getANSBScript method is the task parameter information configured by the user, which includes at least host information, task steps, execution commands, etc. The getANSBScript method is called and the task parameter object (such as taskConfig) is passed in. The phase information, task list, etc. in taskConfig are read in the getANSBScript method, and a script that conforms to the Ansible syntax is generated using the YAML format.
[0075] Here, the getPYTNScript method is called for the Python technology stack to generate a Python-formatted pipeline execution script. The input of the getPYTNScript method is the task parameter information configured by the user, such as the Python code or external command to be executed. The getPYTNScript method is called and the task parameter object (such as taskConfig) is passed in. The getPYTNScript method reads the stage information, command list, etc. in taskConfig and generates a script using the Python language.
[0076] For details, see Figure 3 As shown, it is a flowchart of a method for generating a pipeline execution script provided by an embodiment of the present disclosure, the method comprising steps S1021 to S1022, wherein:
[0077] S1021. Call a preset pipeline parser corresponding to the target technology stack type to parse task parameter information set by the user for the pipeline task.
[0078] S1022. Select a script generation template corresponding to the target technology stack type, embed the task parameter information into the corresponding variables in the script generation template, and generate a pipeline execution script.
[0079] Here, the pipeline parser contains different rules and templates to ensure that the generated pipeline execution script can be executed correctly. In the process of generating the pipeline execution script, the pipeline parser will dynamically configure the script content according to the task parameter information entered by the user. The task parameter information can include variable configuration, execution environment settings, task steps, error handling, etc.
[0080] The pipeline parser replaces the task parameter information into the predefined script template to generate a complete pipeline execution script that meets the technology stack standards. For example, the parser will embed information such as the task number (taskNo) and execution parameters (pipelineExecutionVo) into the script.
[0081] Optionally, the Pipeline Parser can also add standard error handling and logging modules to the Pipeline execution script to ensure that exceptions can be tracked and handled during execution.
[0082] As a possible implementation, after the script is generated, the pipeline parser will perform preliminary verification on the generated script to ensure that it meets the syntax and structure standards of the technology stack. For example, it checks the Jenkinsfile format, Shell command compatibility, Ansible Playbook syntax correctness, or Python script syntax check. The verified script is returned to the task distribution module as the generated result. At this point, the script is ready to be sent to the build environment to be executed in the corresponding technology stack environment.
[0083] This ensures that the system can generate appropriate scripts based on the selected technology stack and prepare for subsequent build and execution steps.
[0084] S103: Send the pipeline execution script to a build environment that matches the target technology stack type for execution.
[0085] In the specific implementation, the corresponding build environment is selected according to the target technology stack type, and the pipeline task is sent to the matching execution platform for execution. If it is the Jenkins technology stack, the task will be sent to the Jenkins server or cluster for execution; for pure Shell scripts, the task will be sent to a server that supports Shell scripts; Ansible scripts will be sent to the Ansible control node for execution; Python scripts will be sent to a build environment suitable for Python execution.
[0086] For details, see Figure 4 As shown, it is a flowchart of a method for executing a pipeline execution script provided by an embodiment of the present disclosure, the method comprising steps S1031 to S1035, wherein:
[0087] S1031. Determine a target build environment that matches the target technology stack type.
[0088] S1032: Create an HTTP request encapsulating the pipeline execution script, and set a corresponding request timeout for the HTTP request.
[0089] S1033. Execute the HTTP request to send the pipeline execution script to the build environment, and receive script execution response information returned by the build environment.
[0090] S1034. Parse the request result included in the script execution response information. When it is determined that the request result is a request failure, record an error log and send process request failure information to the user.
[0091] S1035: When it is determined that the request result is a successful request, the response result included in the script execution response information is parsed; if it is determined that the response result is a failed response, an error log is recorded and a process execution failure information is sent to the user.
[0092] In the specific implementation, the corresponding build environment is selected according to the target technology stack type, and the pipeline task is sent to the matching execution platform for execution. After the target build environment is determined, an HTTP request is created and configured to send the script to the corresponding build environment for execution.
[0093] Here, to ensure the reliability of the request, the request timeouts including the connection timeout, request timeout, and data read timeout can be set through the custom() method of the RequestConfig object. For example, setConnectTimeout(50000) sets the timeout for establishing a connection, setConnectionRequestTimeout(50000) sets the timeout for obtaining a connection, and setSocketTimeout(50000) sets the timeout for reading data. This can prevent the request from being blocked when the network is unstable or the response of the build environment is delayed.
[0094] Optionally, during the process of configuring the HTTP request, determine the target API path corresponding to the build environment; use the HttpPost object to package the pipeline execution script as a POST request; and use the setEntity method to encapsulate the JSON data containing the pipeline execution script into the request body.
[0095] In the specific implementation, the API request URL is first constructed by concatenating apiStartUrl and PIP ELINE_EXECUTION_API to construct a complete API request address and store it in the api variable. This URL is used to make requests to different build environments.
[0096] Here, the full path of the target API is combined by apiStartUrl+PIPELINE_EXECUTION_API, the generated pipeline script is packaged into a POST request using the HttpPost object, the JSON data containing the pipeline execution parameters is encapsulated into the request body through the setEntity method, and the content type is specified as APPLICATION_JSON.
[0097] Further, after the configuration is completed, the HTTP request is executed through httpClientBuilder.build().execute(httpPost) to send the script to the build environment. At this time, wait for the response of the build environment and receive the response to confirm whether the script is successfully received and executed.
[0098] Here, first check whether the response is empty and whether getStatusLine().getStatusCode() is a preset value (for example, 200). If the conditions are not met, it means that the request failed to be sent. In the case of request failure, the error log (logger.error) is recorded and the process request failure information is thrown to help operation and maintenance personnel quickly locate and troubleshoot the problem.
[0099] Here, if the request is successful, the response data of the build environment will continue to be parsed to ensure that the execution status of the task meets expectations. The response content is converted into a string through EntityUtils.toString(response.getEntity()) and checked whether it is empty. If it is empty, the system will record the error log again and throw an exception.
[0100] Among them, using JSON.parseObject(result,new TypeReference <Map<String,Object> >(){}) Parse the response string into a Map<String,Object> The response result in string format is parsed into a JON object and stored in resultMap so that subsequent steps can obtain relevant execution information, such as execution status, log information, etc.
[0101] Here, the resultMap of the response can be analyzed to determine the execution result of the task and handle it according to different situations. For example, if the status returned by the build environment indicates that the task is successfully executed, the system will record the task completion log and continue the subsequent process. If the response result shows that the task execution failed or there is an exception, the system will record the failure reason and trigger the corresponding exception handling process.
[0102] In this way, the generated pipeline script is sent to the corresponding build environment for execution through HTTP requests, and the steps of API URL construction, request configuration, response parsing, and error handling ensure that the task can be reliably sent and the execution status can be monitored.
[0103] The disclosed embodiment provides a pipeline construction method supporting multiple technology stacks. In response to a pipeline task request, the technology stack information indicated in the pipeline task request is parsed, and the target technology stack type corresponding to the technology stack information is determined; a preset pipeline parser corresponding to the target technology stack type is called to generate a pipeline execution script suitable for the target technology stack type; and the pipeline execution script is sent to a construction environment matching the target technology stack type for execution. This allows users to freely select a technology stack when creating a pipeline, automatically generate a corresponding execution script, and send the task to the corresponding construction environment for execution, thereby achieving an efficient and stable automated construction process across technology stacks.
[0104] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0105] Based on the same inventive concept, the embodiments of the present disclosure also provide a pipeline construction device that supports multiple technology stacks corresponding to the pipeline construction method that supports multiple technology stacks. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the above-mentioned pipeline construction method that supports multiple technology stacks in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0106] See also Figure 5 Figure 5 A schematic diagram of a pipeline construction device supporting multiple technology stacks provided by an embodiment of the present disclosure. Figure 5 As shown, the pipeline construction device 500 supporting multiple technology stacks provided by the embodiment of the present disclosure includes:
[0107] The technology stack type determination module 510 parses the technology stack information indicated in the pipeline task request in response to the pipeline task request, and determines the target technology stack type corresponding to the technology stack information.
[0108] The execution script generation module 520 calls a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type.
[0109] The script execution module 530 sends the pipeline execution script to a construction environment matching the target technology stack type for execution.
[0110] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0111] The disclosed embodiment provides a pipeline construction device supporting multiple technology stacks. In response to a pipeline task request, the device parses the technology stack information indicated in the pipeline task request and determines the target technology stack type corresponding to the technology stack information; calls the preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type; and sends the pipeline execution script to a construction environment matching the target technology stack type for execution. This allows users to freely select a technology stack when creating a pipeline, automatically generate a corresponding execution script, and send the task to the corresponding construction environment for execution, thereby achieving an efficient and stable automated construction process across technology stacks.
[0112] Corresponds to Figure 1 The pipeline construction method supporting multiple technology stacks in the present disclosure also provides an electronic device 600, such as Figure 6 FIG. 6 is a schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present disclosure, including:
[0113] Processor 61, memory 62, and bus 63; memory 62 is used to store execution instructions, including memory 621 and external memory 622; memory 621 here is also called internal memory, which is used to temporarily store the operation data in processor 61, and the data exchanged with external memory 622 such as hard disk. Processor 61 exchanges data with external memory 622 through memory 621. When the electronic device 600 is running, the processor 61 communicates with the memory 62 through bus 63, so that the processor 61 executes Figure 1 The steps of the pipeline construction method that supports multiple technology stacks.
[0114] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the pipeline construction method supporting multiple technology stacks described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0115] The embodiments of the present disclosure also provide a computer program product, which includes computer instructions. When the computer instructions are executed by a processor, the steps of the pipeline construction method supporting multiple technology stacks described in the above method embodiment can be executed. For details, please refer to the above method embodiment, which will not be repeated here.
[0116] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0117] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0118] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0119] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0120] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0121] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A pipeline construction method supporting multiple technology stacks, characterized in that: include: In response to a pipeline task request, parsing technology stack information indicated in the pipeline task request, and determining a target technology stack type corresponding to the technology stack information; Calling a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type; The pipeline execution script is sent to a build environment matching the target technology stack type for execution.
2. The method according to claim 1, characterized in that Parsing the technology stack information indicated in the pipeline task request and determining the target technology stack type corresponding to the technology stack information specifically includes: Creating a technology stack map that defines multiple technology stack types, wherein each technology stack type and a corresponding technology stack number are stored in the technology stack map through a key-value pair; According to the received task request identifier corresponding to the pipeline task request, query the technology stack information described in the form of the technology stack number, and check whether the corresponding technology stack number exists in the technology stack mapping; If so, the target technology stack type is determined according to the technology stack number and the mapping relationship stored in the technology stack mapping.
3. The method according to claim 1, characterized in that Calling the preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type, specifically including: Calling a preset pipeline parser corresponding to the target technology stack type to parse the task parameter information set by the user for the pipeline task; A script generation template corresponding to the target technology stack type is selected, and the task parameter information is embedded into the corresponding variables in the script generation template to generate the pipeline execution script.
4. The method according to claim 3, characterized in that The target technology stack type includes at least one of a Jenkins technology stack, a Shell technology stack, an Ansible technology stack, and a Python technology stack; For each type of the target technology stack, call the corresponding script generation method and pass in the task parameter object carrying the task parameter information; In the script generation method, the task parameter information carried in the task parameter object is read, and the task parameter information at least includes stage information and a command list; By executing the script generation method, the pipeline execution script in the format corresponding to the target technology stack type is generated using the syntax specification corresponding to the target technology stack type; Among them, the script generation method corresponding to the Jenkins technology stack is the getPipelineScript method, the script generation method corresponding to the Shell technology stack is the getShellScript method, the script generation method corresponding to the Ansible technology stack is the getANSBScript method, and the script generation method corresponding to the Python technology stack is the getPYTNScript method.
5. The method according to claim 1, characterized in that Sending the pipeline execution script to a build environment matching the target technology stack type for execution, specifically including: Determining a target build environment that matches the target technology stack type; Creating an HTTP request encapsulating the pipeline execution script, and setting a corresponding request timeout for the HTTP request; The HTTP request is executed to send the pipeline execution script to the construction environment, and script execution response information returned by the construction environment is received.
6. The method according to claim 5, characterized in that After receiving the script execution response information returned by the construction environment, the method further includes: Parsing the request result included in the script execution response information, and when determining that the request result is a request failure, recording an error log and sending a process request failure information to the user; When it is determined that the request result is a successful request, the response result included in the script execution response information is parsed; if it is determined that the response result is a failed response, an error log is recorded and process execution failure information is sent to the user.
7. The method according to claim 5, characterized in that Creating an HTTP request encapsulating the pipeline execution script, specifically including: Determine the target API path corresponding to the build environment; Use the HttpPost object to package the pipeline execution script into a POST request; The JSON data containing the pipeline execution script is encapsulated into the request body through the setEntity method.
8. A pipeline construction device supporting multiple technology stacks, characterized in that: include: A technology stack type determination module, configured to, in response to a pipeline task request, parse the technology stack information indicated in the pipeline task request and determine a target technology stack type corresponding to the technology stack information; An execution script generation module is used to call a preset pipeline parser corresponding to the target technology stack type to generate a pipeline execution script suitable for the target technology stack type; The script execution module is used to send the pipeline execution script to a construction environment matching the target technology stack type for execution.
9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the pipeline construction method supporting multiple technology stacks are performed as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the pipeline construction method supporting multiple technology stacks as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for containerizing application program
CN108920250A
Task automatic integration method and device for multiple technology stacks and electronic equipment
CN115291928A
Script testing method and device, computer equipment and storage medium
CN116909888A