Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
In the embodiment of the disclosure, the construction task may be a Jenkins task, which is an open-source continuous integration tool providing a friendly operation interface, and is mainly used for continuously and automatically constructing/testing a software project and monitoring the operation of an external task. And task (Job) is an execution plan for Jenkins, which is a collection of operations. After the Jenkins service is ready, we can create a specific Jenkins Task through the "New Item" of the Web services interface. In the embodiment of the disclosure, the Task mainly aims at the Pipeline type (hereinafter, referred to as Jenkins Pipeline Task)
Wherein Jenkins Pipeline Task can be defined by using Groovy syntax. Specific behaviors defined by Jenkins Pipeline Task include: a Slave node machine for specifically executing tasks is specified through label; defining a self-defined environment variable of the Task runtime; defining different execution phases; a simple built-in sh instruction is used to run a shell script or a python script.
The goals for Jenkins Job operations are diverse, for example: executing the compiling task to generate a compiled product; and executing a deployment task and deploying certain services. In the embodiment of the disclosure, the execution of the compiling task is mainly focused.
When the Jenkins Job is started, a plurality of environment variables can be transmitted to each Job process, so that the currently running task can know the environment of the task when running the custom script, for example: BUILD _ NUMBER, The current built NUMBER, sucas "153"; BUILD _ ID, namely The current BUILD ID, identification to BUILD _ NUMBER for BUILD created in 1.597+, but a YYYY-MM-DD _ hh-MM-ss timemap for stacks; BUILD _ URL, Full URL of this BUILD, like http:// server, port/jenkins/job/foo/15/; JOB _ URL, Full URL of this jobi, like http:// server: port/jenkins/jobo/.
Wherein, BUILD _ NUMBER is a queuing NUMBER of a construction task; BUILD _ ID is the ID of the construction task; BUILD _ URL is a specific Job address of a currently running construction task based on Web access; JOB _ URL: based on Web access, a Task specific Task address is currently constructed.
Fig. 1 is a flowchart of an information processing method provided in an embodiment of the present disclosure, where this embodiment is applicable to a case of extracting target information in a construction task, and the method may be executed by an information processing apparatus, where the apparatus may be composed of hardware and/or software, and may be generally integrated in a device having an information processing function, where the device may be an electronic device such as a server, a mobile terminal, or a server cluster. As shown in fig. 1, the method specifically comprises the following steps:
and step 110, configuring an information extraction function body of the construction task, and injecting the information extraction function body into the construction task.
The information extraction function body can be a function code block written by a native JavaScript code, and the function body can be customized according to actual requirements. In the embodiment of the present disclosure, the form of the information extraction function body may be:
as mentioned above, the information extraction function body extracts the information in the environment variable of the construction task in the running process through three entries of changeInfo, buildInfo and accountInfo.
The method for injecting the information extraction function body into the construction task may be as follows: acquiring an environment variable configuration inlet of a construction task; and adding the information extraction function body to the environment variable of the construction task through the configuration entrance.
In the embodiment of the disclosure, the information extraction function body is a code block stored in a character string form, and the information extraction function body can be added to the environment variable of the construction task through an environment variable configuration entry provided by a Jenkins Web interface. Illustratively, fig. 2 is an exemplary diagram of injecting an information extraction function body into a construction task, as shown in fig. 2, the information extraction function body is injected into the construction task by configuring an environment variable of the construction task, and is named as "isue _ ID _ extactor". The advantage of this may be that the information extraction function body may be obtained by conventional means of obtaining environment variables.
And step 120, acquiring environment variable information of the construction task.
The environment variable information may include environment variable information built in the construction task and Git information submitted by the developer. The built-in environment variable information may include: information such as task sequence number, task link, task name, etc.; the Git information may include specific information such as a topic, a developer name, a mailbox, and the like.
In the embodiment of the disclosure, after the developer submits the code, a patch created event is triggered through a Git warehouse to notify Jenkins to run related construction tasks, and in the construction task running, the built-in environment variable information and Git information submitted by the developer can be acquired.
The acquisition mode can be as follows:
1.const GERRIT_CHANGE_SUBJECT:string=process.env.GERRIT_CHANGE_SUBJECT||”;
2.const GERRIT_CHANGE_URL:string=process.env.GERRIT_CHANGE_URL||”;
3. the function body of the/generator is transferred as an environment variable and can be directly taken
4.const ISSUE_ID_EXTRACTOR:string=process.env.ISSUE_ID_EXTRACTOR||”;。
And step 130, adding context codes to the information extraction function body according to the environment variable information to obtain a target information extraction function.
In the embodiment of the present disclosure, a "context environment" is required to make the information extraction function run, and therefore, context code needs to be added to the information extraction function. The target information extraction function comprises a context code and an information extraction function body.
Specifically, the method for obtaining the target information extraction function by adding the context code to the information extraction function according to the environment variable information may be: adding a context code template to the information extraction function body; and replacing the placeholder variables in the context code template according to the environment variable information.
Wherein, the context module comprises a placeholder variable. Illustratively, the context template may be named extra.tps, and the contents of the context module are as follows:
as with the above file, the extension is "tps" and cannot be run directly, where $ { GERRIT _ XXX } form of the string is the respective placeholder variable and will eventually be replaced by the actual variable. In addition, in order to conveniently obtain each piece of information, the context code template is aggregated aiming at different types of parameters, and the variable naming is more semantic. In the context code template, except for "ISSUE _ ID _ EXTRACTOR", the rest of placeholders need to be expanded by using a single quotation mark. Since "ISSUE _ ID _ EXTRACTOR" itself is going to run as a function, it does not need to be wrapped with a single quotation mark. While the other placeholders are each environment variables passed in as strings and therefore need to be wrapped with a single quotation mark.
In this embodiment of the present disclosure, the process of replacing the placeholder variable in the context code template according to the environment variable information may be: reading a context code template based on a set standard function to obtain a placeholder variable; and replacing the placeholder variable with a corresponding actual variable in the environment variable information.
Wherein, the set standard function may be fs. In the embodiment of the present disclosure, when reading the context code template, the following operations need to be performed first:
1.const EXTRACTER_PATH:string=path.resolve(__dirname,'sandbox/extracter.tps');
2.const EXTRACTER_TPL:string=fs.readFileSync(EXTRACTER_PATH).toString();。
namely, the position of the context code module needs to be determined first, and then reading is performed. For example, the manner of replacing the placeholder variable with the corresponding actual variable in the environment variable information can be as follows:
as can be seen from the above codes, the information extraction function is finally called by an ISSUE _ ID _ exit (changeInfo, buildInfo, accountInfo) statement. changeInfo, buildInfo, accountInfo are three variables defined in the context code template, and the three variables are classified and aggregated for each usable environment variable, so that Jenkins Task administrator can directly access the variables through entries when perfecting the logic of the generator function:
as with the above code, we have direct access to the changeinfo. This variable corresponds to a specific environment variable as: process, env, gerrit _ CHANGE _ reject.
Optionally, before adding the context code to the information extraction function according to the environment variable information, the method further includes the following steps: and adding a calling script for the construction task.
And the calling script is used for executing the operation of adding the context code to the information extraction function body according to the environment variable information when the construction task runs to the setting stage.
In the embodiment of the present disclosure, in order to make the construction task run to the setting stage and execute a certain logic, a script needs to be configured. Illustratively, the following is an example of a calling script of an embodiment of the present disclosure:
as shown above, the configured calling script is a built _ success.ts script that is run after the build task is run successfully, so as to execute the operation of adding context codes to the information extraction function according to the environment variable information.
Optionally, adding a context code to the information extraction function according to the environment variable information may be performed by: and when the construction task runs to the setting stage, adding context codes to the information extraction function body according to the environment variable information.
Illustratively, fig. 3 is a signaling diagram of a process of information in an embodiment of the disclosure. As shown in fig. 3, a task administrator configures an information extraction function for a construction task through an environment variable, starts a static task after successful configuration, runs the construction task by creating a task instance, extracts target information in the construction task by running the configured information extraction function when the construction task runs to a setting stage, and returns a result to the task administrator.
And 140, operating a target information extraction function to obtain target information in the environment variable information.
The target information is information predefined by a target information extraction function.
Optionally, the runtime runs the target information extraction function, and the manner of obtaining the target information in the environment variable information may be: calling a third-party operation library and acquiring a construction function associated with the third-party operation library; creating a function operating environment based on the constructor; and sending the target information extraction function to a function operation environment for operation, and obtaining the target information in the environment variable information.
The third-party runtime library may be implemented by a Sandbox mechanism, for example, a Node Sandbox library. The third party runtime supports the following functions: the method can be used for executing untrusted codes, supporting the ultra-long expiration of execution duration, supporting memory error alarm, supporting elegant error processing, supporting strict modes and the like. The function runtime environment may be a sandbox environment. The manner of obtaining the constructor associated with the third-party runtime library may be: and adopting the grammar of the import association of the Typescript, for example: import Sandbox from 'Sandbox'. The way of creating the function runtime environment may be: a node. Const Sandbox ═ new Sandbox ().
Optionally, the process of operating the target information extraction function to obtain the target information in the environment variable information may be: converting the operation result of the target information extraction function into a character string type; and cutting the running result of the character string type to obtain target information.
The cutting process may be to remove a space before and after the cutting.
In the embodiment of the disclosure, after the target information in the environment variable information is obtained, the return value can be received through the callback function, and then the target information received by the callback function is customized.
In the embodiment of the disclosure, after the target information is obtained, a third-party system may be notified to perform subsequent operations such as state change or additional information addition according to the target information.
Illustratively, fig. 4 is a signaling diagram of a process of information in an embodiment of the disclosure. As shown in fig. 4, when the build task runs to the setting stage, a call script is run, and the context code template is read through the call script; acquiring environment variable information; then replacing the placeholder variable with a corresponding actual variable in the environment variable information; storing the generated information extraction function; calling a third-party operation library; running an information extraction function by a third-party running library; and obtaining the extracted target information by the callback function, and returning the result.
According to the technical scheme of the embodiment of the invention, an information extraction function body of a construction task is configured firstly, the information extraction function body is injected into the construction task, then environment variable information of the construction task is obtained, context codes are added to the information extraction function body according to the environment variable information to obtain a target information extraction function, and finally a running base runs the target information extraction function to obtain target information in the environment variable information. According to the information processing method disclosed by the embodiment of the disclosure, the target information in the construction task is obtained by operating the target information extraction function, and the task construction information can be extracted in a user-defined manner, so that the unified management of the information contained in the environment variable of the construction task is realized.
Fig. 5 is a schematic structural diagram of an information processing apparatus according to an embodiment of the present disclosure, and as shown in fig. 5, the apparatus includes: an information extraction functionbody configuration module 210, an environment variableinformation acquisition module 220, a target information extractionfunction acquisition module 230, and a targetinformation acquisition module 240.
The information extraction functionbody configuration module 210 is configured to configure an information extraction function body of the construction task, and inject the information extraction function body into the construction task;
an environment variableinformation obtaining module 220, configured to obtain environment variable information of a construction task;
a target information extractionfunction obtaining module 230, configured to add a context code to the information extraction function according to the environment variable information, so as to obtain a target information extraction function;
a targetinformation obtaining module 240, configured to run a target information extraction function in the runtime library to obtain target information in the environment variable information; wherein the target information is information predefined by the target information extraction function.
Optionally, the information extraction functionbody configuration module 210 is further configured to:
acquiring an environment variable configuration inlet of a construction task;
and adding the information extraction function body to the environment variable of the construction task through the configuration entrance.
Optionally, the target information extractingfunction obtaining module 230 is further configured to:
adding a context code template to the information extraction function body;
and replacing the placeholder variables in the context code template according to the environment variable information.
Optionally, the target information extractingfunction obtaining module 230 is further configured to:
reading a context code template based on a set standard function to obtain a placeholder variable;
and replacing the placeholder variable with a corresponding actual variable in the environment variable information.
Optionally, the method further includes: a call script adding module for:
adding a calling script for a construction task; the calling script is used for executing the operation of adding context codes to the information extraction function body according to the environment variable information when the construction task runs to the setting stage;
optionally, the target information extractingfunction obtaining module 230 is further configured to:
and when the construction task runs to a setting stage, adding context codes to the information extraction function body according to the environment variable information.
Optionally, the targetinformation extracting module 240 is further configured to:
calling a third-party operation library and acquiring a construction function associated with the third-party operation library;
creating a function operating environment based on the constructor;
and sending the target information extraction function to a function operation environment for operation, and obtaining the target information in the environment variable information.
Optionally, the targetinformation extracting module 240 is further configured to:
converting the operation result of the target information extraction function into a character string type;
and cutting the running result of the character string type to obtain target information.
The device can execute the methods provided by all the embodiments of the disclosure, and has corresponding functional modules and beneficial effects for executing the methods. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in all the foregoing embodiments of the disclosure.
Referring now to FIG. 6, a block diagram of anelectronic device 300 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like, or various forms of servers such as a stand-alone server or a server cluster. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6,electronic device 300 may include a processing means (e.g., central processing unit, graphics processor, etc.) 301 that may perform various appropriate actions and processes in accordance with a program stored in a read-only memory device (ROM)302 or a program loaded from astorage device 305 into a random access memory device (RAM) 303. In theRAM 303, various programs and data necessary for the operation of theelectronic apparatus 300 are also stored. Theprocessing device 301, theROM 302, and theRAM 303 are connected to each other via abus 304. An input/output (I/O)interface 305 is also connected tobus 304.
Generally, the following devices may be connected to the I/O interface 305:input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; anoutput device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like;storage devices 308 including, for example, magnetic tape, hard disk, etc.; and acommunication device 309. The communication means 309 may allow theelectronic device 300 to communicate wirelessly or by wire with other devices to exchange data. While fig. 6 illustrates anelectronic device 300 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program containing program code for performing a method for recommending words. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 305, or installed from theROM 302. The computer program, when executed by theprocessing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: configuring an information extraction function body of a construction task, and injecting the information extraction function body into the construction task; acquiring environment variable information of the construction task; adding context codes to the information extraction function body according to the environment variable information to obtain a target information extraction function; and the running library runs the target information extraction function to obtain the target information in the environment variable information.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the disclosed embodiments, the disclosed embodiments disclose an information processing method, including:
configuring an information extraction function body of a construction task, and injecting the information extraction function body into the construction task;
acquiring environment variable information of the construction task;
adding context codes to the information extraction function body according to the environment variable information to obtain a target information extraction function;
running the target information extraction function to obtain target information in the environment variable information; the target information is information predefined by the target information extraction function.
Further, injecting the information extraction function body into the construction task includes:
acquiring an environment variable configuration inlet of the construction task;
and adding the information extraction function body to the environment variable of the construction task through the configuration entrance.
Further, adding a context code to the information extraction function according to the environment variable information to obtain a target information extraction function, including:
adding a context code template to the information extraction function body;
and replacing the placeholder variable in the context code template according to the environment variable information.
Further, replacing the placeholder variable in the context code template according to the environment variable information includes:
reading the context code template based on a set standard function to obtain a placeholder variable;
and replacing the placeholder variable with a corresponding actual variable in the environment variable information.
Further, before adding context code to the information extraction function according to the environment variable information, the method further includes:
adding a calling script for the construction task; the calling script is used for executing the operation of adding context codes to the information extraction function body according to the environment variable information when the construction task runs to a set stage;
correspondingly, adding a context code to the information extraction function body according to the environment variable information includes:
and when the construction task runs to the setting stage, adding context codes to the information extraction function body according to the environment variable information.
Further, calling a third-party runtime library to run the target information extraction function to extract the target information in the environment variable information, including:
calling a third-party operation library and acquiring a construction function associated with the third-party operation library;
creating a function runtime environment based on the constructor;
and sending the target information extraction function to the function operation environment for operation, and obtaining the target information in the environment variable information.
Further, the running the target information extraction function to obtain the target information in the environment variable information includes:
converting the operation result of the target information extraction function into a character string type;
and cutting the running result of the character string type to obtain target information.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present disclosure and the technical principles employed. Those skilled in the art will appreciate that the present disclosure is not limited to the particular embodiments described herein, and that various obvious changes, adaptations, and substitutions are possible, without departing from the scope of the present disclosure. Therefore, although the present disclosure has been described in greater detail with reference to the above embodiments, the present disclosure is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present disclosure, the scope of which is determined by the scope of the appended claims.