Environment deployment method, device and electronic equipment of version

By adding build deployment files and utilizing packaging scripts to the version's source code, the problems of high manual costs and low efficiency in multi-environment deployment of software are solved, enabling fast and convenient software package deployment.

CN114879976BActive Publication Date: 2025-12-30BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110163811.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-05
Publication Date
2025-12-30
Estimated Expiration
2041-02-05

AI Technical Summary

Technical Problem

In existing technologies, software requires source code modification when deployed in multiple different environments, resulting in high labor costs and low efficiency.

Method used

By adding build and deployment files to the version's source code, the pre-stored packaging script is used to obtain version configuration information, which is then replaced, compiled, and packaged to generate a software package and deployed to the target environment.

Benefits of technology

It enables rapid and convenient deployment of software packages in different environments, reduces the workload of manually modifying source code, and improves deployment efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114879976B_ABST
    Figure CN114879976B_ABST
Patent Text Reader

Abstract

The application provides a version of an environment deployment method, device and electronic equipment, the method is applied to a server, the server pre-stores a packaging script, and the packaging script is run to execute the following steps: obtaining a pre-added build deployment file corresponding to a to-be-deployed version; obtaining version configuration information corresponding to a to-be-deployed environment of the to-be-deployed version; based on the version configuration information, replacing a corresponding part in the to-be-deployed version according to a preset replacement item to generate a new version corresponding to the to-be-deployed version; generating a software package corresponding to the to-be-deployed version according to the new version corresponding to the to-be-deployed version; and deploying the software package corresponding to the to-be-deployed version to the to-be-deployed environment. The application can quickly and conveniently deploy the software package of the to-be-deployed version to different environments through the build deployment file added in the to-be-deployed version.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software technology, and in particular to a method, apparatus and electronic device for environment deployment. Background Technology

[0002] In existing technologies, when a software package needs to be deployed in multiple different environments, the source code can be modified to add configuration information suitable for the new environment, repackaged into a new software package, and then deployed to the target environment. However, this method requires modifying the source code every time it is deployed to a new environment, resulting in high labor costs. Summary of the Invention

[0003] The purpose of this application is to provide a method, apparatus, and electronic device for deploying a version of a software package in different environments by using build deployment files added to the version's source code.

[0004] In a first aspect, embodiments of this application provide a method for deploying a version of an environment. This method is applied to a server, which has a pre-stored packaging script. The packaging script is run to perform the following steps: obtaining a pre-added build deployment file corresponding to the version to be deployed; obtaining version configuration information of the version to be deployed corresponding to the environment to be deployed; based on the version configuration information, replacing the corresponding parts in the version to be deployed according to preset replacement items to generate a new version corresponding to the version to be deployed; generating a software package corresponding to the version to be deployed based on the new version corresponding to the version to be deployed; and deploying the software package corresponding to the version to be deployed in the environment to be deployed.

[0005] Furthermore, the steps described above for obtaining the pre-added build and deployment files corresponding to the version to be deployed include: downloading the corresponding version to be deployed from the source code hosting repository based on the version tag in the script parameters of the packaging script; and extracting the build and deployment files from the version to be deployed.

[0006] Furthermore, the above-mentioned step of obtaining the version configuration information of the deployment environment corresponding to the version to be deployed includes: obtaining the target cluster configuration information corresponding to the specified cluster name from the configuration management center according to the specified cluster name in the script parameters of the packaging script; the target cluster configuration information is a collection of configuration information corresponding to multiple components of the version to be deployed; and using the target cluster configuration information as the version configuration information of the deployment environment corresponding to the version to be deployed.

[0007] Furthermore, the aforementioned version configuration information is in key-value pair format; based on the version configuration information, the steps of replacing the corresponding parts in the version to be deployed according to the preset replacement items include: for the index items of the preset replacement items, searching for the original key value corresponding to the index item in the version to be deployed, searching for the target key value corresponding to the index item in the version configuration information, and replacing the original key value in the version to be deployed with the target key value.

[0008] Furthermore, the steps described above for generating the software package corresponding to the version to be deployed based on the new version to be deployed include: executing a compilation and packaging command based on the pre-configured packaging environment to compile and package the new version to be deployed, thereby obtaining the software package corresponding to the version to be deployed.

[0009] Furthermore, the aforementioned deployment environment includes a container management cluster; the step of deploying the software package corresponding to the version to be deployed to the deployment environment includes: reading the first deployment module in the build deployment file to generate a file for building the image; building the target image corresponding to the version to be deployed based on the file for building the image; and pushing the target image to a preset repository to deploy the software package corresponding to the version to be deployed to the container management cluster based on the target image.

[0010] Furthermore, the aforementioned deployment environment includes a designated server; the step of deploying the software package corresponding to the version to be deployed to the deployment environment includes: reading the second deployment module in the build deployment file to copy the software package corresponding to the version to be deployed to the designated server, and executing a startup command to deploy the software package corresponding to the version to be deployed to the designated server.

[0011] Furthermore, the specified servers mentioned above include one of the following: virtual machines, physical machines, and cloud hosts.

[0012] Secondly, embodiments of this application provide a version environment deployment apparatus. The apparatus is applied to a server, which pre-stores a packaging script. Running the packaging script enables the following module functions: a file acquisition module, used to acquire pre-added build deployment files corresponding to the version to be deployed; a configuration acquisition module, used to acquire version configuration information corresponding to the environment to be deployed for the version to be deployed; a configuration replacement module, used to replace corresponding parts in the version to be deployed according to preset replacement items based on the version configuration information, generating a new version corresponding to the version to be deployed; a software package generation module, used to generate a software package corresponding to the version to be deployed based on the new version corresponding to the version to be deployed; and a version deployment module, used to deploy the software package corresponding to the version to be deployed to the environment to be deployed.

[0013] Thirdly, embodiments of this application also provide an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the method described in the first aspect above.

[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are invoked and executed by a processor, the computer-executable instructions cause the processor to implement the method described in the first aspect above.

[0015] In the environment deployment method provided in this application embodiment, the server pre-stores a packaging script. Running the packaging script executes the following steps: First, obtain the pre-added build deployment file corresponding to the version to be deployed; then, obtain the version configuration information of the version to be deployed corresponding to the environment to be deployed; based on the version configuration information, replace the corresponding parts in the version to be deployed according to preset replacement items to generate a new version corresponding to the version to be deployed; generate the software package corresponding to the version to be deployed based on the new version; and deploy the software package corresponding to the version to be deployed to the environment to be deployed. The method provided in this application embodiment, through the build deployment file added to the source code of the version to be deployed, can quickly and conveniently perform the configuration information replacement, packaging, and deployment process, so that the version to be deployed can be quickly deployed in different environments. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0017] Figure 1 A flowchart illustrating one version of an environment deployment method provided in this application embodiment;

[0018] Figure 2 A flowchart illustrating a source code acquisition method provided in this application embodiment;

[0019] Figure 3 A schematic diagram illustrating one version of the environment deployment method provided in this application embodiment;

[0020] Figure 4 A structural block diagram of an environment deployment device provided in an embodiment of this application;

[0021] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0022] The technical solutions of this application will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0023] The software deployment environment includes basic information such as the domain name and database connection information required for the software version to run. After a software version is developed, it generally needs to be deployed to multiple different environments. In this case, the existing technology adopts the method of modifying the version's source code to add new configurations to adapt it to the new environment. This method requires modifying a large amount of environment-related configuration information each time, resulting in low deployment efficiency and high labor costs.

[0024] Based on this, the present application provides an environment deployment method, apparatus and electronic device. To facilitate understanding of this embodiment, the environment deployment method disclosed in the present application will be described in detail first.

[0025] Figure 1 An environment deployment method provided in this application embodiment is applied to a server. The server has a pre-stored packaging script. Running the packaging script performs the following steps: The environment deployment method provided in this application embodiment includes the following steps:

[0026] Step S102: Obtain the pre-added build deployment file corresponding to the version to be deployed.

[0027] The version to be deployed can be obtained from a local database or from the source code hosting repository based on parameters in the packaging script; no specific limitation is made here.

[0028] The build and deployment file (buildfile.yaml) defines the list of files that need to be replaced, the environment and packaging commands required for packaging, and the files and startup commands required for deployment. In other words, it includes the replacement module, the packaging module, and the deployment module. By reading and scanning this file, the following replacement, packaging, and deployment functions can be implemented.

[0029] It should be noted that the above build and deployment files may require minor adjustments to some replacement items for different versions, but the overall framework and definitions of the files remain unchanged, and all can achieve the functions of replacement, packaging, and deployment.

[0030] Step S104: Obtain the version configuration information corresponding to the environment to be deployed for the version to be deployed.

[0031] For the same version, different version configuration information needs to be configured for different deployment environments. Therefore, it is necessary to first obtain the version configuration information corresponding to the deployment environment for the version to be deployed. This version configuration information can be pre-stored in the server or pre-set by the developers through the configuration management center; no specific limitation is made here.

[0032] Step S106: Based on the version configuration information, replace the corresponding parts in the version to be deployed according to the preset replacement items to generate a new version corresponding to the version to be deployed;

[0033] The `replace` module in the aforementioned deployment file allows for the replacement of configuration information. This means replacing specific information in the version to be deployed with corresponding information from the version's configuration information, ensuring the new version is compatible with the deployment environment. The `replace` module defines a list of files to be replaced, essentially identifying certain index entries. Based on these index entries, the corresponding entries in the version to be deployed and their corresponding configuration entries in the version's configuration information can be found and replaced.

[0034] Step S108: Generate the software package corresponding to the version to be deployed based on the new version corresponding to the version to be deployed.

[0035] After generating the new version corresponding to the version to be deployed, the build module is used to compile and package the software to obtain the package corresponding to the version to be deployed.

[0036] Step S110: Deploy the software package corresponding to the version to be deployed in the environment to be deployed.

[0037] Furthermore, the deploy module described above can be used to deploy the software package corresponding to the version to be deployed to the environment to be deployed. The environment to be deployed can include one of the following: container management cluster, virtual machine, physical machine, and cloud host.

[0038] In the environment deployment method provided in this application embodiment, the server pre-stores a packaging script. Running the packaging script executes the following steps: First, obtain the pre-added build deployment file corresponding to the version to be deployed; obtain the version configuration information of the version to be deployed corresponding to the environment to be deployed; based on the version configuration information, replace the corresponding parts in the version to be deployed according to preset replacement items to generate a new version corresponding to the version to be deployed; generate the software package corresponding to the version to be deployed based on the new version corresponding to the version to be deployed; and deploy the software package corresponding to the version to be deployed to the environment to be deployed. The method provided in this application embodiment, through the build deployment file added to the source code of the version to be deployed, can quickly and conveniently perform the configuration information replacement, packaging, and deployment process, so that the version to be deployed can be quickly deployed in different environments.

[0039] See Figure 2 As shown, the steps described above for obtaining the pre-added build and deployment files corresponding to the version to be deployed can be achieved in the following ways:

[0040] Step S202: Download the corresponding version to be deployed from the source code hosting repository according to the version tag in the script parameters of the packaging script;

[0041] Step S204: Extract the build deployment files from the version to be deployed.

[0042] In practical applications, the script parameters of the packaging script are pre-configured by the user. The version tag in the script parameters is called the version tag. By using this tag, the corresponding version to be deployed can be downloaded from the Git source code hosting repository, thereby extracting the build and deployment files corresponding to the version to be deployed.

[0043] With numerous deployment environments and software packages, managing the configurations of different versions can be difficult and prone to errors. Therefore, to facilitate the management of version configuration information and reduce user configuration modification operations, this embodiment utilizes the Apollo configuration center to manage version configuration information. Apollo is an open-source configuration management center developed by Ctrip's framework department. It can centrally manage the configurations of applications in different environments and clusters. After configuration modifications, they can be pushed to the application in real time, and it has standardized permissions, process governance, and other features.

[0044] Developers pre-configure version information in the Apollo configuration center. One version corresponds to one Apollo cluster. An Apollo cluster can have multiple namespaces. One namespace corresponds to the configuration information of a version component. The configuration information of a version component can include multiple configuration information stored as key-value pairs. Therefore, an Apollo cluster is essentially a collection of configuration information corresponding to each component in a version.

[0045] The script parameters mentioned above also include specifying the cluster name, such as the Apollo cluster name. This name can be used to obtain the target cluster configuration information corresponding to the Apollo cluster name from the configuration management center, such as the Apollo configuration center, when performing configuration information replacement. This is the collection of configuration information corresponding to multiple components of the version to be deployed, and then the subsequent configuration replacement process can be executed.

[0046] Since the version configuration information in the Apollo configuration center is in key-value pair format, the corresponding configuration can be replaced in the following ways:

[0047] For the index entries of the preset replacement items, the original key value corresponding to the index entry is found in the version to be deployed, and the target key value corresponding to the index entry is found in the version configuration information. The original key value in the version to be deployed is then replaced with the target key value.

[0048] The index entries for the aforementioned preset replacement items refer to the keys in the replacement list within the replace module. These keys can be used to find the corresponding original key value from the source code or the corresponding target key value from the version configuration information, and then the original key value is replaced with the target key value. These index entries can include the namespace corresponding to the specified Apollo cluster name and the keys within that namespace, thus allowing the replacement of specific configuration information within a specific version of a component.

[0049] In practice, the system scans the replacement list defined in the `replace` module within `buildfile.yaml`. Each value in the list corresponds to a file in the version to be deployed. The system then scans the `$` symbol in each file.<variable_name> Replace `$` with the corresponding value obtained from the Apollo configuration center.

[0050] The steps described above for generating the software package corresponding to the version to be deployed based on the new version can be achieved in the following ways:

[0051] The compilation and packaging command is executed based on the pre-configured packaging environment to compile and package the new version corresponding to the version to be deployed, resulting in the software package corresponding to the version to be deployed.

[0052] The `build` module in the aforementioned build deployment file has already configured the environment required for packaging and the commands to compile and package. Therefore, through this `build` module, the compilation and packaging commands can be executed based on the pre-configured packaging environment to compile and package the new code corresponding to the version to be deployed, thus obtaining the software package corresponding to the version to be deployed.

[0053] Figure 3 A schematic diagram of a packaging process provided by an embodiment of this application is shown, which can help to better understand the method of the embodiment of this application, and will not be described in detail here.

[0054] There are two scenarios for deploying software packages, and different deployment methods can be adopted for different environments:

[0055] The first scenario involves a container management cluster, such as a Kubernetes cluster, as the environment to be deployed. In this case, an image needs to be built. However, in existing technologies, a separate Dockerfile needs to be written for each version to package the image, and each team needs to learn Dockerfile syntax, resulting in a high learning cost. In this embodiment, the image can be quickly built and deployed using the aforementioned build and deployment file, as detailed below:

[0056] Read the first deployment module in the build deployment file to generate a file for building the image; build the target image corresponding to the version to be deployed based on the file for building the image; push the target image to a preset repository, such as a hub repository, so that the software package corresponding to the version to be deployed can be deployed on the K8S cluster based on the target image.

[0057] In practice, the first deployment module in the build deployment file is read to generate a Dockerfile (a text file containing instructions and descriptions for building an image). Based on the Dockerfile, the target image corresponding to the version to be deployed is built using the `docker build` command. This target image, or Docker image, is a special file system that provides the necessary programs, libraries, resources, and configuration files for container runtime, as well as runtime configuration parameters (such as anonymous volumes, environment variables, and users). The image does not contain any dynamic data, and its content remains unchanged after building. Then, the `docker push` command pushes the target image to the hub repository, allowing it to be used on the Kubernetes cluster. This replaces the old image in the corresponding service deployment in the Kubernetes cluster with the target image, completing the service deployment.

[0058] The second scenario involves a designated server as the deployment environment, which can be a virtual machine, a physical machine, or a cloud host. In this case, the second deployment module in the build deployment file is read to copy the software package corresponding to the version to be deployed to the designated server, and the startup command is executed to deploy the software package corresponding to the version to be deployed to the designated server.

[0059] In practice, the `deploy` module within the `buildfile` is parsed to copy the deployment files to the specified server and execute the startup command. The `deploy` module defines the runtime dependencies (`require` module), the initialization commands (`init` module) required at the start of deployment), and the software startup command (`start` module). This completes the version deployment process on the specified server.

[0060] In this application embodiment, the buildfile.yaml file can be implemented in various programming languages, including but not limited to: Java, Python, Go, PHP, etc.

[0061] The environment deployment method provided in this application uses the Apollo configuration center to manage the configuration information of each version, reducing user workload. A unified buildfile defines each part of the software version, from replacing environment configurations to compilation, packaging, deployment, and operation. That is, software versions are deployed through unified deployment scripts and specifications, generating customized Docker images for each software version component. Users do not need to learn Docker programming; they only need to write normal packaging and startup commands into the script, resulting in a very low learning curve. By parsing the unified buildfile, Dockerfile files can be generated in real time to compile images or directly deployed to remote environments, enabling convenient and rapid deployment of versions in different environments, such as different customer environments, cloud hosts or physical machines, and Kubernetes clusters.

[0062] Based on the above method embodiments, this application also provides a version of an environment deployment device. This device is applied to a server, which pre-stores a packaging script. Running the packaging script enables the following module functions, see [link to relevant documentation]. Figure 4 As shown, the environment deployment apparatus provided in this application embodiment includes:

[0063] The file acquisition module 402 is used to acquire the pre-added build and deployment files corresponding to the version to be deployed;

[0064] The configuration acquisition module 404 is used to obtain the version configuration information of the deployment environment corresponding to the version to be deployed;

[0065] The configuration replacement module 406 is used to replace the corresponding parts in the version to be deployed according to the preset replacement items based on the version configuration information, and generate a new version corresponding to the version to be deployed.

[0066] The package generation module 408 is used to generate the package corresponding to the version to be deployed based on the new version corresponding to the version to be deployed;

[0067] Version deployment module 410 is used to deploy the software package corresponding to the version to be deployed to the environment to be deployed.

[0068] Furthermore, the file acquisition module 402 is also used to download the corresponding version to be deployed from the source code hosting repository according to the version tag in the script parameters of the packaging script; and extract the build deployment file from the version to be deployed.

[0069] Furthermore, the configuration acquisition module 404 is also used to obtain the target cluster configuration information corresponding to the specified cluster name from the configuration management center according to the specified cluster name in the script parameters of the packaging script; the target cluster configuration information is a collection of configuration information corresponding to multiple components of the version to be deployed; and the target cluster configuration information is used as the version configuration information of the version to be deployed corresponding to the environment to be deployed.

[0070] Furthermore, the aforementioned version configuration information is in key-value pair format; the aforementioned configuration replacement module 406 is also used to, for each index item of the preset replacement item, search for the original key value corresponding to the index item in the version to be deployed, search for the target key value corresponding to the index item in the version configuration information, and replace the original key value in the version to be deployed with the target key value.

[0071] Furthermore, the aforementioned package generation module 408 is also used to execute compilation and packaging commands based on the pre-configured packaging environment, compile and package the new version corresponding to the version to be deployed, and obtain the package corresponding to the version to be deployed.

[0072] Furthermore, the aforementioned environment to be deployed includes a container management cluster; the aforementioned version deployment module 410 is also used to read the first deployment module in the build deployment file to generate a file for building the image; build the target image corresponding to the version to be deployed based on the file for building the image; and push the target image to a preset repository so as to deploy the software package corresponding to the version to be deployed on the container management cluster based on the target image.

[0073] Furthermore, the aforementioned deployment environment includes a designated server; the aforementioned version deployment module 410 is also used to read the second deployment module in the build deployment file to copy the software package corresponding to the version to be deployed to the designated server, and execute a startup command to deploy the software package corresponding to the version to be deployed on the designated server.

[0074] Furthermore, the specified servers mentioned above include one of the following: virtual machines, physical machines, and cloud hosts.

[0075] The implementation principle and technical effects of the environment deployment device provided in this application are the same as those of the aforementioned environment deployment method embodiments. For the sake of brevity, any parts of the environment deployment device embodiments not mentioned in the previous versions can be referred to the corresponding content in the aforementioned environment deployment method embodiments.

[0076] This application also provides an electronic device, such as... Figure 5 The diagram shows the structure of the electronic device, which includes a processor 51 and a memory 50. The memory 50 stores computer-executable instructions that can be executed by the processor 51, and the processor 51 executes the computer-executable instructions to implement the above-described method.

[0077] exist Figure 5 In the illustrated embodiment, the electronic device further includes a bus 52 and a communication interface 53, wherein the processor 51, the communication interface 53, and the memory 50 are connected via the bus 52.

[0078] The memory 50 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 53 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 52 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 52 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0079] The processor 51 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 51 or by instructions in software form. The processor 51 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in the memory, and the processor 51 reads the information in the memory and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiment.

[0080] This application also provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above-described method. For specific implementation details, please refer to the foregoing method embodiments, which will not be repeated here.

[0081] The computer program products of the environment deployment method, apparatus and electronic device provided in the embodiments of this application include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.

[0082] Unless otherwise specifically stated, the relative steps, numerical expressions, and values ​​of the components and steps described in these embodiments do not limit the scope of this application.

[0083] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0084] In the description of this application, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0085] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the technical scope disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A method for deploying an environment of versions, characterized by, The method is applied to a server, the server pre-stores a packaging script, and the packaging script is run to perform the following steps: obtaining pre-added build deployment files corresponding to a to-be-deployed version; obtaining version configuration information corresponding to a to-be-deployed environment of the to-be-deployed version; based on the version configuration information, replacing a corresponding part in the to-be-deployed version according to a preset replacement item to generate a new version corresponding to the to-be-deployed version; generating a software package corresponding to the to-be-deployed version according to the new version corresponding to the to-be-deployed version; deploying the software package corresponding to the to-be-deployed version to the to-be-deployed environment; The version configuration information is in the form of a key-value pair. Based on the version configuration information, the step of replacing the corresponding part in the to-be-deployed version according to the preset replacement item comprises: for the index item of the preset replacement item, the original key value corresponding to the index item is found from the to-be-deployed version, the target key value corresponding to the index item is found from the version configuration information, and the original key value in the to-be-deployed version is replaced with the target key value; wherein the build deployment file includes a replacement module, and the replacement module defines a file list to be replaced; the index item of the preset replacement item refers to the key in the file list in the replacement module.

2. The method of claim 1, wherein, The step of obtaining pre-added build deployment files corresponding to a to-be-deployed version comprises: downloading the corresponding to-be-deployed version from a source code hosting repository according to the version label in the script parameters of the packaging script; extracting the build deployment file from the to-be-deployed version.

3. The method of claim 1, wherein, The step of obtaining version configuration information corresponding to a to-be-deployed environment of the to-be-deployed version comprises: obtaining target cluster configuration information corresponding to a specified cluster name from a configuration management center according to the specified cluster name in the script parameters of the packaging script; the target cluster configuration information is a set of configuration information corresponding to a plurality of components corresponding to the to-be-deployed version; the target cluster configuration information is used as the version configuration information corresponding to the to-be-deployed environment of the to-be-deployed version.

4. The method of claim 1, wherein, The step of generating a software package corresponding to the to-be-deployed version according to the new version corresponding to the to-be-deployed version comprises: performing a compilation and packaging command based on a pre-configured packaging required environment to compile and package the new version corresponding to the to-be-deployed version to obtain the software package corresponding to the to-be-deployed version.

5. The method of claim 1, wherein, The to-be-deployed environment includes a container management cluster; The step of deploying the software package corresponding to the to-be-deployed version to the to-be-deployed environment comprises: reading a first deployment module in the build deployment file to generate a file for building an image; building a target image corresponding to the to-be-deployed version according to the file for building an image; pushing the target image to a preset repository to deploy the software package corresponding to the to-be-deployed version to the container management cluster based on the target image.

6. The method of claim 1, wherein, The to-be-deployed environment includes a specified server; The step of deploying the software package corresponding to the to-be-deployed version to the to-be-deployed environment comprises: reading a second deployment module in the build deployment file to copy the software package corresponding to the to-be-deployed version to the specified server and execute a start command to deploy the software package corresponding to the to-be-deployed version on the specified server.

7. The method of claim 6, wherein, The specified server comprises one of a virtual machine, a physical machine and a cloud host.

8. An environment deployment apparatus of a version, characterized by, The device is applied to a server, and the server pre-stores a packaging script. A file obtaining module is configured to obtain a pre-added build deployment file corresponding to a to-be-deployed version. A configuration obtaining module is configured to obtain version configuration information corresponding to a to-be-deployed environment of the to-be-deployed version. A configuration replacing module is configured to replace a corresponding part in the to-be-deployed version according to a preset replacement item based on the version configuration information to generate a new version corresponding to the to-be-deployed version. A software package generating module is configured to generate a software package corresponding to the to-be-deployed version according to the new version corresponding to the to-be-deployed version. A version deploying module is configured to deploy the software package corresponding to the to-be-deployed version on the to-be-deployed environment. The version configuration information is in a key-value pair form. The configuration replacing module is further configured to: For an index item of the preset replacement item, the original key value corresponding to the index item is found from the to-be-deployed version, the target key value corresponding to the index item is found from the version configuration information, and the original key value in the to-be-deployed version is replaced with the target key value.

9. An electronic device, comprising: The computer readable storage medium stores computer executable instructions, and the computer executable instructions, when invoked and executed by a processor, cause the processor to implement the method in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and the computer executable instructions, when invoked and executed by a processor, cause the processor to implement the method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Web system version deployment method, web system version deployment device and storage medium

    CN108829433A

  • Multi-environment project deployment method and device, storage medium and processor

    CN109725911A