CN115576574A - Code packaging method, device, medium and equipment - Google Patents

Code packaging method, device, medium and equipment Download PDF

Info

Publication number
CN115576574A
CN115576574A CN202211391496.0A CN202211391496A CN115576574A CN 115576574 A CN115576574 A CN 115576574A CN 202211391496 A CN202211391496 A CN 202211391496A CN 115576574 A CN115576574 A CN 115576574A
Authority
CN
China
Prior art keywords
code
environment
target
environment variable
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211391496.0A
Other languages
Chinese (zh)
Inventor
何辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202211391496.0A priority Critical patent/CN115576574A/en
Publication of CN115576574A publication Critical patent/CN115576574A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a code packing method, a device, a medium and equipment, wherein the method comprises the following steps: acquiring a code to be packaged of a target project and a target packaging environment of the code to be packaged; acquiring target environment variable data corresponding to a target packaging environment in a preset environment variable mapping table, wherein the target environment variable data comprise at least one environment variable and an environment variable value of each environment variable; identifying the code field of each environment variable in the code to be packaged based on the target environment variable data, and replacing the code field of the environment variable with the environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged; and packaging the object code. According to the method, the environment setting information in the code is automatically modified, the packed file is automatically generated, the environment information in the code is not required to be manually modified, the workload of developers is reduced, the working efficiency of the developers is improved, and the accuracy of code modification is also improved.

Description

Code packaging method, device, medium and equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a code packing method, apparatus, medium, and device.
Background
The application program on the terminal is a software program which is composed of a large number of codes, and a code developer is required to write codes and a tester is required to perform functional testing during the process of forming the application program. As software programs are upgraded and updated, code developers need to continuously update codes and submit new codes, and testers need to test the codes to ensure that the codes can run correctly and achieve expected functions. Before testing the code, a code developer must compile and package the code to generate a package.
The code is stored with environment information related to the test environment, different environment information represents different test environments, and when the code is tested, corresponding tests need to be carried out under the matched test environment. Usually, a code developer modifies the environment information in the code according to the test environment requirements provided by the tester, and then packages the code for modifying the environment information. And the tester stores the packed file in a matched test environment to test the code.
There are many kinds of test environments for each code, and code packing is performed once for each test of one test environment. According to the test environment, a code developer manually modifies the environment information in the codes and then modifies the codes of the environment information for packaging, if the test environments to be tested by the tester in a certain day are various, the code developer needs to manually modify the environment information in the codes for many times, the codes are packaged for many times, the workload of the code developer is increased invisibly, and the working efficiency is reduced.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, a medium, and a device for packaging a code, and mainly aims to solve the problems that at present, a code developer manually modifies environment configuration information in a code according to a requirement of a tester, so that the workload of the code developer is increased, and the work efficiency is reduced.
According to an aspect of the present application, there is provided a code packing method, including:
acquiring a code to be packaged of a target project and a target packaging environment of the code to be packaged;
acquiring target environment variable data corresponding to the target packaging environment in a preset environment variable mapping table, wherein the target environment variable data comprises at least one environment variable and an environment variable value of each environment variable;
identifying a code field of each environment variable in the code to be packaged based on the target environment variable data, and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain a target code corresponding to the code to be packaged;
and packaging the object code.
Optionally, before the target environment variable data corresponding to the target packaging environment is obtained from the preset environment variable mapping table, the method further includes:
determining preset test environments corresponding to at least one preset project, wherein the preset test environment corresponding to each preset project comprises at least one preset test environment;
acquiring variable configuration information of each preset test environment corresponding to any preset project, wherein the variable configuration information comprises at least one preset environment variable and a corresponding preset environment variable value;
generating a preset environment variable mapping table according to variable configuration information corresponding to the preset project, wherein the preset environment variable mapping table comprises a preset test environment of the preset project, and the preset environment variable and the corresponding preset environment variable value under the preset test environment.
Optionally, obtaining a target packaging environment of the code to be packaged includes:
receiving a code packing instruction aiming at a target project;
if the code packaging instruction comprises to-be-tested environment information, determining the target packaging environment based on the to-be-tested environment information;
and if the code packaging instruction does not include the to-be-tested environment information, acquiring a preset testing environment corresponding to the target project in the preset environment variable mapping table as the target packaging environment.
Optionally, the identifying, based on the target environment variable data, a code field of each environment variable in the code to be packaged, and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged includes:
acquiring an environment configuration code field in the code to be packaged according to a preset code rule;
identifying a code field of each environment variable in the environment configuration code field according to target environment variable data corresponding to the target packaging environment;
and replacing the code field of each environment variable with the environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged.
Optionally, the obtaining the code to be packaged includes:
receiving a code packing instruction aiming at a target project;
and pulling the code to be packaged corresponding to the target project from a code management platform, wherein the code management platform is used for storing the project code submitted by a code developer.
Optionally, the packaging the object code includes:
compiling the object code;
selecting a first format file from the engineering file of the compiled object code, and converting the first format file into a second format file;
and packaging the project file after the file format conversion to obtain a packaged file.
Optionally, the object code is compiled using a project building tool.
According to another aspect of the present application, there is provided a code packaging apparatus including:
the system comprises a to-be-packaged data acquisition module, a to-be-packaged data acquisition module and a to-be-packaged data acquisition module, wherein the to-be-packaged data acquisition module is used for acquiring a to-be-packaged code of a target project and a target packaging environment of the to-be-packaged code;
a target environment variable data obtaining module, configured to obtain target environment variable data corresponding to the target packaging environment in a preset environment variable mapping table, where the target environment variable data includes at least one environment variable and an environment variable value of each environment variable;
the replacing module is used for identifying the code field of each environment variable in the code to be packaged based on the target environment variable data, replacing the code field of the environment variable with the environment variable value of the environment variable, and obtaining the target code corresponding to the code to be packaged;
and the packaging module is used for packaging the object code.
Optionally, the code packaging apparatus further comprises:
the system comprises a preset test environment determining module, a data processing module and a data processing module, wherein the preset test environment determining module is used for determining preset test environments corresponding to at least one preset project, and the preset test environment corresponding to each preset project comprises at least one;
the system comprises a variable configuration information acquisition module, a parameter configuration information acquisition module and a parameter configuration information acquisition module, wherein the variable configuration information acquisition module is used for acquiring variable configuration information of each preset test environment corresponding to any preset project, and the variable configuration information comprises at least one preset environment variable and a corresponding preset environment variable value;
and the preset environment variable mapping table generating module is used for generating a preset environment variable mapping table according to the variable configuration information corresponding to the preset project, wherein the preset environment variable mapping table comprises a preset test environment of the preset project, and the preset environment variable and the corresponding preset environment variable value under the preset test environment.
Optionally, the to-be-packaged data obtaining module is further configured to:
receiving a code packing instruction aiming at a target project;
if the code packaging instruction comprises to-be-tested environment information, determining the target packaging environment based on the to-be-tested environment information;
and if the code packaging instruction does not include the to-be-tested environment information, acquiring a preset testing environment corresponding to the target project in the preset environment variable mapping table as the target packaging environment.
Optionally, the replacement module is further configured to:
acquiring an environment configuration code field in the code to be packaged according to a preset code rule;
according to target environment variable data corresponding to the target packaging environment, identifying a code field of each environment variable in the environment configuration code field;
and replacing the code field of each environment variable with the environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged.
Optionally, the to-be-packaged data obtaining module is further configured to:
receiving a code packing instruction aiming at a target project;
and pulling the code to be packaged corresponding to the target project from a code management platform, wherein the code management platform is used for storing the project code submitted by a code developer.
Optionally, the packaging module is further configured to:
compiling the object code;
selecting a first format file from the engineering file of the compiled object code, and converting the first format file into a second format file;
and packaging the project file after the file format conversion to obtain a packaged file.
Optionally, the object code is compiled using a project building tool.
According to another aspect of the present application, a storage medium is provided, where at least one executable instruction is stored in the storage medium, and the executable instruction causes a processor to perform operations corresponding to the code packing method.
According to another aspect of the present application, there is provided a computer device including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the code packaging method.
By the technical scheme, the technical scheme provided by the embodiment of the invention at least has the following advantages:
the application provides a code packing method, device, equipment and medium, target environment variable data corresponding to a target packing environment are obtained, the target environment variable data comprise environment variables and environment variable values of the environment variables, the code fields of the environment variables in the codes to be packed are replaced by the environment variable values of the environment variables, target codes are obtained, a packing file is packed and generated for the target codes, automatic modification of environment setting information in the codes is achieved, the packing file is generated automatically, manual modification of the environment information in the codes is not needed, workload of developers is reduced, working efficiency of developers is improved, and accuracy of code modification is improved.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 shows a flowchart of a code packaging method provided in an embodiment of the present application;
FIG. 2 is a flow chart of another code packaging method provided by the embodiment of the present application;
FIG. 3 is a flow chart illustrating a further method for packaging code provided by an embodiment of the present application;
FIG. 4 is a flow chart illustrating a further method for packaging code provided by an embodiment of the present application;
FIG. 5 is a flowchart illustrating another code packaging method provided by an embodiment of the present application;
FIG. 6 is a block diagram illustrating a code packaging apparatus provided in an embodiment of the present application;
fig. 7 shows a schematic structural diagram of a computer device according to an embodiment of the present invention.
Wherein the content of the first and second substances,
in FIG. 6: 602-a data to be packaged acquisition module; 604-target environment variable data acquisition module; 606-a replacement module; 608-a packing module;
in fig. 7: 702-a processor; 704 — a communication interface; 706-a memory; 708-a communication bus; 710-procedure.
Detailed Description
The invention will be described in detail hereinafter with reference to the drawings and embodiments. It should be noted that the embodiments and features of the embodiments of the present invention may be combined with each other without conflict.
To further illustrate the technical means and effects of the present invention adopted to achieve the predetermined objects, the following detailed description of the embodiments, structures, characteristics and effects according to the present invention will be made with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "an embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Aiming at the problems that the current code developer modifies the environment configuration information in the code manually according to the requirements of testers, the workload of the code developer is increased, and the working efficiency of the developer is reduced, the embodiment of the application provides a code packaging method, as shown in fig. 1, the method comprises the following steps:
102: acquiring a code to be packaged of a target project and a target packaging environment of the code to be packaged;
the method includes the steps that firstly, installation files of APP (application programs) on a terminal are formed after codes are packaged, in order to meet the requirements of users, the APPs need to be updated and upgraded continuously, the codes corresponding to the APPs need to be modified continuously, code developers package the codes generated for the first time or the modified codes during upgrading into files in combination with environment configuration information, testers test the packaged files in a matched test environment, different environment configuration information forms different packaged files, and the packaged files passing the test can be used as the installation files of the APPs.
And the developer manually replaces the environment configuration information set in the code according to the environment configuration information provided by the tester to generate a packaged file corresponding to the environment configuration information. Different environment configuration information generates different packed files, and because manual replacement is needed, the working efficiency is low, and replacement errors are easy, the invention provides a code packing method for automatically replacing the environment configuration information in the code.
In the embodiment of the invention, the code packaging method is realized by a script program, a developer or a tester starts the script program, the script program acquires the codes to be packaged of the target project pushed by the developer through a code pushing platform or a code storage platform, acquires the target packaging environment corresponding to the codes to be packaged, and sets the environment configuration information in the codes to be packaged into the configuration information matched with the target packaging environment.
The code to be packaged includes but is not limited to content of operations performed by insurance business, medical service, claim settlement operation, public service, financial service, logistics management, and the like, and therefore the code packaging method includes but is not limited to application scenarios of insurance business, medical service, claim settlement operation, public service, financial service, logistics management, and the like.
In another embodiment of the present invention, for further limitation and explanation, the obtaining a code to be packaged includes:
receiving a code packing instruction aiming at a target project;
and pulling the code to be packaged corresponding to the target project from a code management platform, wherein the code management platform is used for storing the project code submitted by a code developer.
In this embodiment, a code developer sends written codes to a code management platform, and when a packaging person needs to start a packaging script program, the packaging script program receives a code packaging instruction and then obtains the codes to be packaged on the code management platform. The code management platform can be a Git branch management platform, and can also be any platform for storing front-end submitted codes.
In another embodiment of the present invention, for further definition and explanation, as shown in fig. 2, the obtaining of the target packaging environment of the code to be packaged includes:
202: receiving a code packing instruction aiming at a target project;
204: if the code packaging instruction comprises the to-be-tested environment information, determining a target packaging environment based on the to-be-tested environment information;
206: and if the code packing instruction does not comprise the to-be-tested environment information, acquiring a preset test environment corresponding to the target project in a preset environment variable mapping table as a target packing environment.
In this embodiment, the code packing instruction includes a storage path of the code to be packed and environment information to be tested, and the code to be packed is obtained according to the storage path of the code to be packed.
And when the to-be-tested environment information comprises the testing environment type, taking a preset testing environment corresponding to the testing environment type in the to-be-tested environment information as a target packaging environment. For example, the to-be-tested environment information of the to-be-packaged code includes an environment a, and if the preset test environment includes the environment a, the environment a is used as the target packaging environment. For example, the to-be-tested environment information of the to-be-packaged code includes an environment a, an environment B and an environment C, if the preset test environment includes the environment a and the environment C, the environment a and the environment C are respectively used as a target packaging environment, and each target packaging environment generates a packaging file.
When the to-be-tested environment information does not include the testing environment type or the included environment type is not matched with the preset testing environment in the preset environment variable mapping table, all the preset testing environments corresponding to the preset projects the same as the target project are obtained from the preset environment variable mapping table, and each preset testing environment corresponding to the preset projects the same as the target project is used as a target packaging environment. For example, the J preset project is the same as the target project, and the preset test environment corresponding to the J preset project includes an environment a, an environment B and an environment C, and then the environment a, the environment B and the environment C are respectively used as a target packaging environment, and each target packaging environment generates a packaging file.
104: acquiring target environment variable data corresponding to a target packaging environment in a preset environment variable mapping table, wherein the target environment variable data comprises at least one environment variable and an environment variable value of each environment variable;
in the embodiment of the invention, after the target packaging environment is determined, a group of target environment variable data corresponding to each target packaging environment is obtained in the preset environment variable mapping table, and the environment variable in the code to be packaged is replaced according to the target environment variable data. Each set of target environment variable data includes a plurality of environment variables and environment variable values of each of the environment variables, for example, environment variable values 111 including environment variables AA and AA, environment variable values 222 including environment variable BB and environment variable BB, environment variable values 333 including environment variable CC and environment variable CC, environment variable values 444 including environment variable DD and environment variable DD, and the like.
The target environment variable data is used for generating a test environment or an APP use environment, including but not limited to insurance business, product sales, product after-sale, product inventory management, logistics management, medical services, claim settlement operation and other use environments.
In another embodiment of the present invention, for further limitation and description, as shown in fig. 3, before obtaining target environment variable data corresponding to a target packaging environment in a preset environment variable mapping table, the code packaging method further includes:
302: determining preset test environments corresponding to at least one preset project, wherein the preset test environment corresponding to each preset project comprises at least one preset test environment;
304: acquiring variable configuration information of each preset test environment corresponding to any preset project, wherein the variable configuration information comprises at least one preset environment variable and a corresponding preset environment variable value;
306: and generating a preset environment variable mapping table according to the variable configuration information corresponding to the preset project, wherein the preset environment variable mapping table comprises a preset test environment of the preset project, a preset environment variable under the preset test environment and a corresponding preset environment variable value.
In the embodiment of the present invention, a preset project represents a code project corresponding to an APP, and a developer or a tester determines multiple preset test environments corresponding to each preset project according to work experience or a use scenario of the APP, each preset test environment corresponds to a set of variable configuration information, each set of variable configuration information includes multiple preset environment variables and preset environment variable values corresponding to the multiple preset environment variables, for example, a set of variable configuration information set according to a preset environment includes an environment variable value 1010 of a preset environment variable XX and the preset environment variable XX, an environment variable value 1020 of a preset environment variable YY and the preset environment variable YY, and an environment variable value 1030 of a preset environment variable ZZ and the preset environment variable ZZ. The preset environment variable mapping table stores each preset test environment, and a preset environment variable value corresponding to each preset test environment.
106: identifying a code field of each environment variable in the code to be packaged based on the target environment variable data, and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain a target code corresponding to the code to be packaged;
in another embodiment of the present invention, for further limitation and description, as shown in fig. 4, identifying a code field of each environment variable in the code to be packaged based on the target environment variable data, and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain an object code corresponding to the code to be packaged, where the method includes:
402: acquiring an environment configuration code field in a code to be packaged according to a preset code rule;
404: identifying a code field of each environment variable in an environment configuration code field according to target environment variable data corresponding to a target packaging environment;
406: and replacing the code field of each environment variable with the environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged.
In the embodiment of the invention, after target environment variable data corresponding to each target packaging environment is obtained in a preset environment variable mapping table, an environment configuration code field is firstly obtained in a code to be packaged, a code field of each environment variable is obtained in the environment configuration code field according to the target environment variable data corresponding to one target packaging environment, and the code field of each environment variable is replaced by an environment variable value of the environment variable. If 5 target packaging environments are determined, code replacement is carried out on the 5 target packaging environments, 5 replaced target codes are obtained, and then packaging is carried out on each target code.
For example, for an environment variable k corresponding to a target packaging environment, the variable value of the environment variable k is 88, in a code to be packaged, if a code field of the environment variable k is composed of the environment variable and an environment variable placeholder, the environment variable placeholder is obtained in an environment configuration code field, the environment variable placeholder is obtained by identifying an equation between the environment variable k and the environment variable placeholder, and the environment variable placeholder in the equation between the environment variable k and the environment variable placeholder is replaced with the variable value 88 of the environment variable k.
In one embodiment, the default environment variable mapping table is stored on the device that performs the code packaging, any other database, server, configuration center, etc. that may be stored and read from as needed.
108: and packaging the object code.
In another embodiment of the present invention, for further definition and explanation, as shown in fig. 5, the packing of the object code includes:
502: compiling the object code;
504: selecting a first format file from the engineering file of the compiled object code, and converting the first format file into a second format file;
506: and packaging the project file after the file format conversion to obtain a packaged file.
In this embodiment, one package file is generated for each object code generated in the target package environment, and finally, 5 package files are generated if there are 5 target package environments.
When the object code generated under an object packaging environment is packaged, the object code is compiled firstly, then the files with the format of class in the engineering files of the compiled object code are converted into the files with the format of apv, and after the file formats are converted, all the files in the engineering files of the object code are packaged to form an installation file with the format of apk or a file package with the format of jar.
In one embodiment, the object code is compiled using a project building tool.
In the embodiment of the invention, the project construction tool mainly adopts a gradle project construction tool or a Maven project construction tool to compile the object code and convert the format of the file in the project file of the object code.
The application provides a code packing method, compared with the prior art, obtain the target environment variable data that the target packing environment corresponds, target environment variable data includes the environment variable value of environment variable and environment variable, will wait to pack the environment variable's in the code field replacement for the environment variable value of environment variable, obtain the target code, pack the generation package file to the target code, realize the environment setting information in the automatic modification code, the automatic generation package file, need not artifical environmental information in the manual modification code, the work load of developer has been reduced, developer's work efficiency has been improved, the degree of accuracy of code modification has still been improved.
Further, as an implementation of the method shown in fig. 1, an embodiment of the present invention provides a code packaging apparatus, as shown in fig. 6, where the apparatus includes:
a to-be-packaged data obtaining module 602, configured to obtain a to-be-packaged code of a target project and a target packaging environment of the to-be-packaged code;
a target environment variable data obtaining module 604, configured to obtain target environment variable data corresponding to a target packaging environment in a preset environment variable mapping table, where the target environment variable data includes at least one environment variable and an environment variable value of each environment variable;
a replacing module 606, configured to identify a code field of each environment variable in the code to be packaged based on the target environment variable data, and replace the code field of the environment variable with an environment variable value of the environment variable, so as to obtain a target code corresponding to the code to be packaged;
and a packaging module 608 for packaging the object code.
The application provides a code packing apparatus, compared with the prior art, obtain the target environment variable data that the target packing environment corresponds, target environment variable data includes the environment variable value of environment variable and environment variable, the environment variable value of environment variable will be waited to replace for the environment variable in the packing code, obtain the target code, generate the packing file to the target code packing, realize the environment setting information in the automatic modification code, the automatic generation packing file, need not artifical environmental information in the manual modification code, developer's work load has been reduced, developer's work efficiency has been improved, the degree of accuracy of code modification has still been improved.
In one embodiment, the code packaging apparatus further comprises:
the system comprises a preset test environment determining module, a data processing module and a data processing module, wherein the preset test environment determining module is used for determining preset test environments corresponding to at least one preset project, and the preset test environment corresponding to each preset project comprises at least one;
the variable configuration information acquisition module is used for acquiring variable configuration information of each preset test environment corresponding to any preset project, wherein the variable configuration information comprises at least one preset environment variable and a preset environment variable value corresponding to the preset environment variable;
the preset environment variable mapping table generating module is used for generating a preset environment variable mapping table according to the variable configuration information corresponding to the preset project, wherein the preset environment variable mapping table comprises a preset test environment of the preset project, a preset environment variable under the preset test environment and a corresponding preset environment variable value.
In one embodiment, the to-be-packaged data obtaining module 602 is further configured to:
receiving a code packing instruction aiming at a target project;
if the code packaging instruction comprises the to-be-tested environment information, determining a target packaging environment based on the to-be-tested environment information;
and if the code packaging instruction does not include the to-be-tested environment information, acquiring a preset testing environment corresponding to the target project in a preset environment variable mapping table as the target packaging environment.
In one embodiment, the replacement module 606 is further configured to:
acquiring an environment configuration code field in a code to be packaged according to a preset code rule;
according to target environment variable data corresponding to a target packaging environment, identifying a code field of each environment variable in an environment configuration code field;
and replacing the code field of each environment variable with the environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged.
In one embodiment, the to-be-packaged data obtaining module 602 is further configured to:
receiving a code packing instruction aiming at a target project;
and pulling the code to be packaged corresponding to the target project from a code management platform, wherein the code management platform is used for storing the project code submitted by a code developer.
In one embodiment, the packaging module 608 is further configured to:
compiling the object code;
selecting a first format file from the engineering files of the compiled object codes, and converting the first format file into a second format file;
and packaging the project file after the file format conversion to obtain a packaged file.
In one embodiment, the object code is compiled using a project building tool.
According to an embodiment of the present invention, there is provided a storage medium storing at least one executable instruction, where the computer executable instruction can execute the code packaging method in any of the method embodiments described above.
Fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present invention, where the embodiment of the present invention does not limit the specific implementation of the computer device.
As shown in fig. 7, the computer apparatus may include: a processor (processor) 702, a communication Interface 704, a memory 706, and a communication bus 708.
Wherein: the processor 702, communication interface 704, and memory 706 communicate with each other via a communication bus 708.
A communication interface 704 for communicating with network elements of other devices, such as clients or other servers.
The processor 702 is configured to execute the program 710, and may specifically perform relevant steps in the above code packaging method embodiment.
In particular, the program 710 may include program code comprising computer operating instructions.
The processor 702 may be a central processing unit CPU, or an Application Specific Integrated Circuit ASIC (Application Specific Integrated Circuit), or one or more Integrated circuits configured to implement an embodiment of the present invention. The computer device includes one or more processors, which may be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
The memory 706 stores a program 710. The memory 706 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 710 may be specifically configured to cause the processor 702 to perform the following operations:
acquiring a code to be packaged of a target project and a target packaging environment of the code to be packaged;
acquiring target environment variable data corresponding to a target packaging environment in a preset environment variable mapping table, wherein the target environment variable data comprises at least one environment variable and an environment variable value of each environment variable;
identifying a code field of each environment variable in the code to be packaged based on the target environment variable data, and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain a target code corresponding to the code to be packaged;
and packaging the object code.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented in a general purpose computing device, centralized on a single computing device or distributed across a network of computing devices, and in one embodiment, may be implemented in program code executable by a computing device, such that the steps shown and described may be executed by a computing device stored in a memory device and, in some cases, executed in a sequence other than that described herein, or fabricated separately as individual integrated circuit modules or fabricated as a single integrated circuit module from multiple modules or steps of the above. Thus, the present invention is not limited to any specific combination of hardware and software.
The above embodiments are only exemplary embodiments of the present application, and are not intended to limit the present application, and the protection scope of the present application is defined by the claims. Various modifications and equivalents may be made by those skilled in the art within the spirit and scope of the present application and such modifications and equivalents should also be considered to be within the scope of the present application.

Claims (10)

1. A method of packaging code, comprising:
acquiring a code to be packaged of a target project and a target packaging environment of the code to be packaged;
acquiring target environment variable data corresponding to the target packaging environment in a preset environment variable mapping table, wherein the target environment variable data comprise at least one environment variable and an environment variable value of each environment variable;
identifying a code field of each environment variable in the code to be packaged based on the target environment variable data, and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain a target code corresponding to the code to be packaged;
and packaging the object code.
2. The code packaging method according to claim 1, wherein before obtaining the target environment variable data corresponding to the target packaging environment in the preset environment variable mapping table, the method further comprises:
determining preset test environments corresponding to at least one preset project, wherein the preset test environment corresponding to each preset project comprises at least one preset test environment;
acquiring variable configuration information of each preset test environment corresponding to any preset project, wherein the variable configuration information comprises at least one preset environment variable and a corresponding preset environment variable value;
generating a preset environment variable mapping table according to variable configuration information corresponding to the preset project, wherein the preset environment variable mapping table comprises a preset test environment of the preset project, and the preset environment variable and the corresponding preset environment variable value under the preset test environment.
3. The code packaging method of claim 2, wherein obtaining a target packaging environment for code to be packaged comprises:
receiving a code packing instruction aiming at a target project;
if the code packing instruction comprises environment information to be tested, determining the target packing environment based on the environment information to be tested;
and if the code packaging instruction does not comprise the environment information to be tested, acquiring a preset test environment corresponding to the target project in the preset environment variable mapping table as the target packaging environment.
4. The code packaging method according to claim 1, wherein the identifying, based on the target environment variable data, a code field of each environment variable in the code to be packaged and replacing the code field of the environment variable with an environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged comprises:
acquiring an environment configuration code field in the code to be packaged according to a preset code rule;
identifying a code field of each environment variable in the environment configuration code field according to target environment variable data corresponding to the target packaging environment;
and replacing the code field of each environment variable with the environment variable value of the environment variable to obtain the target code corresponding to the code to be packaged.
5. The code packaging method of claim 1, wherein the obtaining the code to be packaged comprises:
receiving a code packing instruction aiming at a target project;
and pulling the code to be packaged corresponding to the target project from a code management platform, wherein the code management platform is used for storing the project code submitted by a code developer.
6. The code packaging method of claim 1, wherein said packaging the object code comprises:
compiling the object code;
selecting a first format file from the engineering file of the compiled object code, and converting the first format file into a second format file;
and packaging the project file after the file format conversion to obtain a packaged file.
7. The code packaging method of claim 6, wherein the object code is compiled using a project building tool.
8. A code packaging apparatus, comprising:
the system comprises a to-be-packaged data acquisition module, a to-be-packaged data acquisition module and a to-be-packaged code acquisition module, wherein the to-be-packaged data acquisition module is used for acquiring a to-be-packaged code of a target project and a target packaging environment of the to-be-packaged code;
a target environment variable data obtaining module, configured to obtain target environment variable data corresponding to the target packaging environment in a preset environment variable mapping table, where the target environment variable data includes at least one environment variable and an environment variable value of each environment variable;
the replacing module is used for identifying the code field of each environment variable in the code to be packaged based on the target environment variable data, replacing the code field of the environment variable with the environment variable value of the environment variable, and obtaining the target code corresponding to the code to be packaged;
and the packaging module is used for packaging the object code.
9. A storage medium having stored therein at least one executable instruction that causes a processor to perform operations corresponding to the code packaging method of any of claims 1-7.
10. A computer device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the code packaging method of any one of claims 1-7.
CN202211391496.0A 2022-11-08 2022-11-08 Code packaging method, device, medium and equipment Pending CN115576574A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211391496.0A CN115576574A (en) 2022-11-08 2022-11-08 Code packaging method, device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211391496.0A CN115576574A (en) 2022-11-08 2022-11-08 Code packaging method, device, medium and equipment

Publications (1)

Publication Number Publication Date
CN115576574A true CN115576574A (en) 2023-01-06

Family

ID=84589187

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211391496.0A Pending CN115576574A (en) 2022-11-08 2022-11-08 Code packaging method, device, medium and equipment

Country Status (1)

Country Link
CN (1) CN115576574A (en)

Similar Documents

Publication Publication Date Title
CN111399853B (en) Templated deployment method for machine learning model and custom operator
CN108319460B (en) Method and device for generating application program installation package, electronic equipment and storage medium
US11667033B2 (en) Systems and methods for robotic process automation
CN109032631B (en) Application program patch package obtaining method and device, computer equipment and storage medium
CN111158741B (en) Method and device for monitoring dependency relationship change of service module on third party class library
CN108920359B (en) Application program testing method and device, storage medium and electronic device
CN112286829B (en) Test script generation method and device
CN112394942A (en) Distributed software development compiling method and software development platform based on cloud computing
CN112769706B (en) Componentized routing method and system
US10866803B2 (en) Generating interaction libraries
CN109614325B (en) Method and device for determining control attribute, electronic equipment and storage medium
CN115185550A (en) Service deployment method, device, computer equipment and storage medium
US11422917B2 (en) Deriving software application dependency trees for white-box testing
CN116755713A (en) Application program generation method, device, equipment and storage medium
CN111240987B (en) Method and device for detecting migration program, electronic equipment and computer readable storage medium
CN115576574A (en) Code packaging method, device, medium and equipment
CN115048082A (en) Micro front-end system construction method and device, server and readable storage medium
CN114021133A (en) Code processing method and device, electronic equipment and storage medium
US20220019522A1 (en) Automated sequencing of software tests using dependency information
CN113220586A (en) Automatic interface pressure test execution method, device and system
CN111367512B (en) Method and device for creating Android library module dependency relationship in application development
CN107291494B (en) Method and device for generating application program installation package
CN117873607A (en) Processing method and device for target operation corresponding to custom function
CN117130895A (en) Interface testing method, device, electronic equipment and medium
CN116820970A (en) Program testing method, device, medium and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination