Jenkins task processing method and device, electronic equipment and storage medium
By obtaining Jenkins configuration information, establishing secure communications and obtaining access tokens, and automatically triggering or canceling Jenkins tasks, the problem of manually operating Jenkins GUI is solved, improving deployment efficiency and reducing GUI operation requirements.
Patent Information
- Application Number
- CN202411520378.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-14
AI Technical Summary
In the existing technology, projects that have not yet been configured for automated CI/CD processes, developers need to log in to the Web GUI of continuous integration services such as Jenkins and manually click the deployment button to trigger the construction and deployment process, resulting in cumbersome operations, inefficient and breaking the immersive development experience. .
By obtaining configuration information for Jenkins, establishing secure communication with the Jenkins server, obtaining access protection tokens, and building request information to automatically trigger or cancel Jenkins tasks.
It realizes the function of directly automatically triggering and canceling Jenkins tasks in development tools, improves deployment efficiency and reduces the operational needs of third-party GUIs.
Smart Images

Figure CN119440549A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a Jenkins task processing method, device, electronic device and storage medium. Background Art
[0002] In the modern software development process, CI (Continuous Integration) / CD (Continuous Deployment) has become the key to improving development efficiency and code quality. However, for projects that have not yet configured an automated CI / CD process, developers usually need to log in to the Web (World Wide Web) GUI (Graphical User Interface) of continuous integration services such as Jenkins and manually click the deployment button to trigger the build and deployment process. Summary of the invention
[0003] The present invention provides a Jenkins task processing method, device, electronic device and storage medium to realize the function of directly and automatically triggering and canceling Jenkins tasks in development tools, thereby improving deployment efficiency and reducing the operation requirements of a third-party GUI.
[0004] According to one aspect of the present invention, a method for processing a Jenkins task is provided, the method comprising:
[0005] Get configuration information for Jenkins;
[0006] Establish secure communication with the Jenkins server according to the user credential information in the configuration information, and obtain an access protection token from the Jenkins server;
[0007] Build request information according to the user credential information, the access protection token and the path of the pending Jenkins task, so that the Jenkins server processes the pending Jenkins task according to the processing method carried in the request information.
[0008] According to another aspect of the present invention, a Jenkins task processing device is provided, the device comprising:
[0009] Configuration information acquisition module, used to obtain configuration information for Jenkins;
[0010] A token acquisition module, used to establish secure communication with the Jenkins server according to the user credential information in the configuration information, and obtain an access protection token from the Jenkins server;
[0011] The task processing module is used to construct request information according to the user credential information, the access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information.
[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0013] at least one processor; and
[0014] a memory communicatively connected to the at least one processor; wherein,
[0015] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the Jenkins task processing method described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the Jenkins task processing method described in any embodiment of the present invention when executed.
[0017] The technical solution of the embodiment of the present invention obtains configuration information for Jenkins; establishes secure communication with the Jenkins server according to the user credential information in the configuration information, and obtains an access protection token from the Jenkins server; constructs request information according to the user credential information, the access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information, and adopts a technical means of sending a processing request to the Jenkins server on the basis of establishing a secure communication channel with the Jenkins server, so that the Jenkins server automatically processes the Jenkins task. This solves the existing problem that for projects that have not yet configured an automated CI / CD process, developers usually need to log in to the Web GUI of continuous integration services such as Jenkins and manually click the deployment button to trigger the build and deployment process, which has the problems of cumbersome operation, low efficiency and breaking the immersive development experience. The function of directly and automatically triggering and canceling Jenkins tasks in the development tool is realized, thereby improving deployment efficiency and reducing the operation requirements of the third-party GUI.
[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A flowchart of a Jenkins task processing method provided in Embodiment 1 of the present invention;
[0021] Figure 2 A schematic diagram of the structure of a Jenkins task processing device provided in Embodiment 2 of the present invention;
[0022] Figure 3 It is a structural schematic diagram of an electronic device for implementing the method for processing a Jenkins task according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] Embodiment 1
[0026] Figure 1This is a flowchart of a Jenkins task processing method provided in the first embodiment of the present invention. This embodiment is applicable to the case of constructing or canceling a Jenkins task. The method can be executed by a Jenkins task processing device. The Jenkins task processing device can be implemented in the form of hardware and / or software. The Jenkins task processing device can be configured in a computer that deploys a Node.js development environment. Figure 1 As shown, the method includes:
[0027] S110. Obtain configuration information for Jenkins.
[0028] The configuration information may refer to setting information for Jenkins tasks, Jenkins servers, etc. based on the processing requirements of the current Jenkins tasks.
[0029] In this embodiment, configuration information for Jenkins can be obtained by configuring specified environment variables or creating a .env file in a local machine or a continuous integration environment.
[0030] Exemplarily, the environment variables may include JENKINS_URL (i.e., the uniform resource locator of the Jenkins server), JOB_NAME (i.e., the task name), JENKINS_USER (i.e., the user name of Jenkins), and JENKINS_TOKEN (i.e., the application programming interface API token of Jenkins).
[0031] S120. Establish secure communication with the Jenkins server according to the user credential information in the configuration information, and obtain an access protection token from the Jenkins server.
[0032] The user credential information may refer to the authentication information of the user accessing the Jenkins server. The user credential information may include a user name (JENKINS_USER) and an interface token (i.e., JENKINS_TOKEN). The user name may refer to an account name, etc., and the interface token may refer to an API token. The access protection token may refer to a Crumb token used to prevent cross-site request forgery (CSRF) attacks.
[0033] In this embodiment, before processing a Jenkins task on the Jenkins server, it is necessary to establish a communication connection with the Jenkins server and ensure the security of the communication connection. Specifically, the identity can be verified to the Jenkins server using the user credential information in the configuration information, and an access protection token can be obtained from the Jenkins server to ensure secure access to the Jenkins server.
[0034] In an optional implementation, establishing secure communication with the Jenkins server based on the user credential information in the configuration information may include: performing data conversion processing on the user name and interface token to obtain processed user credential information, wherein the processed user credential information satisfies the verification data format of the Jenkins server; and enabling the Jenkins server to verify the user identity based on the processed user credential information, so that the user establishes secure communication with the Jenkins server.
[0035] In this embodiment, the fs module of Node.js can be used to read the .env file or read the configuration information for Jenkins from the environment variables to obtain the user name and API token. Further, the Buffer module of Node.js can be used to perform Base64 encoding (i.e., data conversion processing) on the user name and API token so that the data of the user name and API token can be recognized by the Jenkins server, and generate an Authorization header (i.e., processed user credential information) for the HTTP request, thereby establishing secure communication with the Jenkins server using basic authentication based on the Authorization header.
[0036] In an optional implementation, obtaining an access protection token from a Jenkins server may include: constructing a first request based on processed user credential information, and sending the first request to an access protection token interface of the Jenkins server; parsing response data of the Jenkins server to the first request to obtain the access protection token.
[0037] The first request may refer to a request for obtaining an access protection token. The access protection token interface may refer to a path of the Jenkins server for sending an access protection token, for example, the / crumbIssuer / api / json interface of the Jenkins server.
[0038] Exemplarily, the Authorization header can be added to the GET request to construct a first request, and the first request is sent according to the path / crumbIssuer / api / json of the access protection token interface, and the response data of the Jenkins server for the first request is obtained. The response data is parsed to obtain the Crumb token.
[0039] S130, constructing request information according to the user credential information, the access protection token and the path of the pending Jenkins task, so that the Jenkins server processes the pending Jenkins task according to the processing method carried in the request information.
[0040] The path of the pending Jenkins task may refer to the path of the Jenkins task on the Jenkins server, and the path of the pending Jenkins task may include the task name of the pending Jenkins task. The pending Jenkins task may include a pending Jenkins task to be built and a pending Jenkins task to be canceled. The path of the pending Jenkins task to be built may be, for example, / job / {JOB_NAME} / build, and the path of the pending Jenkins task to be canceled may be, for example, / job / {JOB_NAME} / lastBuild / stop. The request information may be a POST request, and the request header of the request information may include Authorization and Crumb information. The processing method carried in the request information may refer to a processing method such as build or cancel, and the processing method may be confirmed from the path of the pending Jenkins task. For example, the processing method corresponding to the path / job / {JOB_NAME} / build is "build", i.e., build, and the processing method corresponding to the path / job / {JOB_NAME} / lastBuild / stop is "stop", i.e., stop or cancel.
[0041] Optionally, request information is constructed based on user credential information, access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information. This may include: constructing a second request based on the processed user credential information, access protection token and the task path of the Jenkins task to be triggered, so that the Jenkins server triggers the construction of the Jenkins task to be triggered according to the second request; constructing a third request based on the processed user credential information, access protection token and the task path of the Jenkins task to be canceled, so that the Jenkins server cancels the Jenkins task to be canceled according to the third request.
[0042] Exemplarily, the second request may be constructed as follows:
[0043]
[0044]
[0045] The second request in the above example contains the path " / job / ${encodeURIComponent(JOB_NAME)} / build", the request method is a POST request, and the request header contains Authorization and crumb information. Sending the above second request to the Jenkins server can trigger the Jenkins task.
[0046] Exemplarily, the third request may be constructed as follows:
[0047]
[0048] The third request in the above example contains the path " / job / ${encodeURIComponent(JOB_NAME)} / lastBuild / stop", the request method is a POST request, and the request header contains Authorization and crumb information. Sending the third request to the Jenkins server can cancel the running Jenkins task.
[0049] The technical solution of the embodiment of the present invention obtains configuration information for Jenkins; establishes secure communication with the Jenkins server according to the user credential information in the configuration information, and obtains an access protection token from the Jenkins server; constructs request information according to the user credential information, the access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information, and adopts a technical means of sending a processing request to the Jenkins server on the basis of establishing a secure communication channel with the Jenkins server, so that the Jenkins server automatically processes the Jenkins task. This solves the existing problem that for projects that have not yet configured an automated CI / CD process, developers usually need to log in to the Web GUI of continuous integration services such as Jenkins and manually click the deployment button to trigger the build and deployment process, which has the problems of cumbersome operation, low efficiency and breaking the immersive development experience. The function of directly and automatically triggering and canceling Jenkins tasks in the development tool is realized, thereby improving deployment efficiency and reducing the operation requirements of the third-party GUI.
[0050] Optionally, the configuration information may also include a task processing result feedback method. Exemplarily, the environment variable corresponding to the task processing result feedback method may be FEEDBACK_TYPE (i.e., the feedback type of the Jenkins task processing result), and FEEDBACK_TYPE may be configured as three methods: FEEDBACK_TYPE=notification / email / all, i.e., the task processing result feedback method may include system-level message prompts (notification) and / or email notifications (email).
[0051] Correspondingly, the Jenkins task processing method may also include: obtaining the response status code of the Jenkins server to the request information, and identifying the processing result of the Jenkins server on the Jenkins task to be processed according to the response status code; and providing feedback on the processing result according to the task processing result feedback method.
[0052] The response status code can be used to indicate whether the processing result of the Jenkins task being processed by the Jenkins server is successful or failed.
[0053] In this embodiment, the processing result of the pending Jenkins task is identified according to the response status code fed back by the Jenkins server, and according to the pre-configured task processing result feedback method, system-level message prompts, email notifications, or both methods are selected to timely feedback the operation results, including "deployment successful", "deployment failed", "cancellation successful" and "cancellation failed" and other information.
[0054] Optionally, the task processing result feedback method includes system-level message prompts and / or email notifications; when the task processing result feedback method is system-level message prompts, the feedback information is constructed based on the processing results and the information subject; when the task processing result feedback method is email notifications, the feedback information is constructed based on the processing results and the email recipients.
[0055] In this embodiment, when performing system-level message prompts, node-notifier can be used for system-level message prompts. When performing email notifications, nodemailer can be used to send email notifications to a specified recipient list. When using both notification methods at the same time, both node-notifier and nodemailer can be used.
[0056] In summary, this embodiment uses the native network communication module of Node.js to communicate with the Jenkins server via HTTP. The security of the request is ensured through basic authentication. The Crumb token is obtained to satisfy the CSRF (Cross-site request forgery) protection mechanism of Jenkins to prevent unauthorized requests.
[0057] When triggering or canceling Jenkins tasks, all requests contain the necessary authentication information and security tokens, ensuring the security and reliability of communications.
[0058] By introducing node-notifier and nodemailer, multiple result feedback methods are implemented. According to the configuration of environment variables, developers and related personnel can get timely feedback on operation results through system-level message prompts and / or email notifications. Email notifications are particularly suitable for situations where other members of the team need to be informed of the operation results, meeting the needs of team collaboration.
[0059] This embodiment automates the deployment and cancellation of Jenkins tasks, and can automatically trigger or cancel build tasks without manually operating the Jenkins interface, thereby improving the efficiency of deployment and maintenance. Through configuration, you can choose to use system-level message prompts, email notifications, or both methods at the same time, which can meet the needs of different scenarios and personnel, and timely feedback allows developers to obtain operation results immediately, reducing waiting and query time and improving work efficiency. Basic authentication and CSRF protection mechanisms are used to ensure the security of communication with the Jenkins server. Using API tokens instead of passwords further enhances security. In addition to node-notifier and nodemailer, this solution is implemented through the native module of Node.js, reducing the complexity and maintenance cost of the project. This solution can run in any environment that supports Node.js, and is suitable for restricted environments or scenarios where a large number of external libraries cannot be installed.
[0060] Embodiment 2
[0061] Figure 2 A schematic diagram of the structure of a Jenkins task processing device provided in the second embodiment of the present invention. Figure 2 As shown, the device includes: a configuration information acquisition module 210, a token acquisition module 220 and a task processing module 230. Among them:
[0062] Configuration information acquisition module 210, used to obtain configuration information for Jenkins;
[0063] A token acquisition module 220, configured to establish secure communication with the Jenkins server according to the user credential information in the configuration information, and to obtain an access protection token from the Jenkins server;
[0064] The task processing module 230 is used to construct request information according to the user credential information, the access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information.
[0065] The technical solution of the embodiment of the present invention obtains configuration information for Jenkins; establishes secure communication with the Jenkins server according to the user credential information in the configuration information, and obtains an access protection token from the Jenkins server; constructs request information according to the user credential information, the access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information, and adopts a technical means of sending a processing request to the Jenkins server on the basis of establishing a secure communication channel with the Jenkins server, so that the Jenkins server automatically processes the Jenkins task. This solves the existing problem that for projects that have not yet configured an automated CI / CD process, developers usually need to log in to the Web GUI of continuous integration services such as Jenkins and manually click the deployment button to trigger the build and deployment process, which has the problems of cumbersome operation, low efficiency and breaking the immersive development experience. The function of directly and automatically triggering and canceling Jenkins tasks in the development tool is realized, thereby improving deployment efficiency and reducing the operation requirements of the third-party GUI.
[0066] Optionally, the user credential information includes a user name and an interface token;
[0067] Accordingly, the token acquisition module 220 can be specifically used for:
[0068] Performing data conversion processing on the user name and the interface token to obtain processed user credential information, wherein the processed user credential information satisfies the verification data format of the Jenkins server;
[0069] The Jenkins server is enabled to verify the identity of the user according to the processed user credential information, so that the user can establish secure communication with the Jenkins server.
[0070] Optionally, the token acquisition module 220 may be further used for:
[0071] Constructing a first request according to the processed user credential information, and sending the first request to an access protection token interface of the Jenkins server;
[0072] Parse the response data of the Jenkins server to the first request to obtain the access protection token.
[0073] Optionally, the task processing module 230 may be specifically used for:
[0074] Constructing a second request according to the processed user credential information, the access protection token and the task path of the to-be-triggered Jenkins task, so that the Jenkins server triggers construction of the to-be-triggered Jenkins task according to the second request;
[0075] A third request is constructed according to the processed user credential information, the access protection token and the task path of the Jenkins task to be canceled, so that the Jenkins server cancels the Jenkins task to be canceled according to the third request.
[0076] Optionally, the configuration information also includes a task processing result feedback method.
[0077] Optionally, the Jenkins task processing device further includes a task processing result feedback module, which is used to:
[0078] Obtaining a response status code of the Jenkins server to the request information, and identifying a processing result of the Jenkins server on the pending Jenkins task according to the response status code;
[0079] The processing result is fed back according to the task processing result feedback method.
[0080] Optionally, the task processing result feedback method includes system-level message prompt and / or email notification;
[0081] In the case where the task processing result feedback mode is a system-level message prompt, the feedback information is constructed according to the processing result and the information subject;
[0082] In the case where the task processing result feedback method is email notification, the feedback information is constructed according to the processing result and the email recipient.
[0083] The Jenkins task processing device provided in the embodiment of the present invention can execute the Jenkins task processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0084] Embodiment 3
[0085] Figure 3 A schematic diagram of an electronic device 300 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers or various forms of mobile devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0086] like Figure 3As shown, the electronic device 300 includes at least one processor 301, and a memory connected to the at least one processor 301, such as a read-only memory (ROM) 302, a random access memory (RAM) 303, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 301 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 302 or the computer program loaded from the storage unit 308 to the random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 can also be stored. The processor 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0087] A number of components in the electronic device 300 are connected to the I / O interface 305, including: an input unit 306, such as a keyboard, a mouse, etc.; an output unit 307, such as various types of displays, speakers, etc.; a storage unit 308, such as a disk, an optical disk, etc.; and a communication unit 309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 309 allows the electronic device 300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0088] The processor 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 301 executes the various methods and processes described above, such as the processing method of the Jenkins task.
[0089] In some embodiments, the processing method of the Jenkins task may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via the ROM 302 and / or the communication unit 309. When the computer program is loaded into the RAM 303 and executed by the processor 301, one or more steps of the processing method of the Jenkins task described above may be performed. Alternatively, in other embodiments, the processor 301 may be configured to execute the processing method of the Jenkins task in any other appropriate manner (e.g., by means of firmware).
[0090] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0091] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0092] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0093] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0094] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0095] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0096] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0097] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for processing a Jenkins task, characterized in that: include: Get configuration information for Jenkins; Establish secure communication with the Jenkins server according to the user credential information in the configuration information, and obtain an access protection token from the Jenkins server; Build request information according to the user credential information, the access protection token and the path of the pending Jenkins task, so that the Jenkins server processes the pending Jenkins task according to the processing method carried in the request information.
2. The method according to claim 1, characterized in that The user credential information includes a user name and an interface token; Establish secure communication with the Jenkins server based on the user credential information in the configuration information, including: Performing data conversion processing on the user name and the interface token to obtain processed user credential information, wherein the processed user credential information satisfies the verification data format of the Jenkins server; The Jenkins server is enabled to verify the identity of the user according to the processed user credential information, so that the user can establish secure communication with the Jenkins server.
3. The method according to claim 2, characterized in that Obtain an access protection token from the Jenkins server, including: Constructing a first request according to the processed user credential information, and sending the first request to an access protection token interface of the Jenkins server; Parse the response data of the Jenkins server to the first request to obtain the access protection token.
4. The method according to claim 2, characterized in that: Constructing request information according to the user credential information, the access protection token and the path of the pending Jenkins task, so that the Jenkins server processes the pending Jenkins task according to the processing method carried in the request information, including: Constructing a second request according to the processed user credential information, the access protection token and the task path of the to-be-triggered Jenkins task, so that the Jenkins server triggers construction of the to-be-triggered Jenkins task according to the second request; A third request is constructed according to the processed user credential information, the access protection token and the task path of the Jenkins task to be canceled, so that the Jenkins server cancels the Jenkins task to be canceled according to the third request.
5. The method according to claim 1, characterized in that The configuration information also includes a task processing result feedback method.
6. The method according to claim 5, characterized in that Also includes: Obtaining a response status code of the Jenkins server to the request information, and identifying a processing result of the Jenkins server on the pending Jenkins task according to the response status code; The processing result is fed back according to the task processing result feedback method.
7. The method according to claim 6, characterized in that The task processing result feedback method includes system-level message prompts and / or email notifications; In the case where the task processing result feedback mode is a system-level message prompt, the feedback information is constructed according to the processing result and the information subject; In the case where the task processing result feedback method is email notification, the feedback information is constructed according to the processing result and the email recipient.
8. A Jenkins task processing device, characterized in that: include: Configuration information acquisition module, used to obtain configuration information for Jenkins; A token acquisition module, used to establish secure communication with the Jenkins server according to the user credential information in the configuration information, and obtain an access protection token from the Jenkins server; The task processing module is used to construct request information according to the user credential information, the access protection token and the path of the Jenkins task to be processed, so that the Jenkins server processes the Jenkins task to be processed according to the processing method carried in the request information.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the Jenkins task processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the Jenkins task processing method described in any one of claims 1 to 7 when executed.