Detailed Description
In the prior art, the automatic deployment process is completely realized only by Jenkins related plug-ins, and once the requirement that the plug-ins cannot be realized appears, the automatic deployment cannot be realized. While the infrastructure is developed based on Python, integrates the advantages of a plurality of operation and maintenance tools (puppet, cfengine, chef, func, fabric), and realizes functions of batch system configuration, batch program deployment, batch operation commands and the like. In the process of compiling the front-end code or the back-end code based on the infrastructure tool, other relevant plug-ins do not need to be loaded, and the compiling work can be guaranteed not to be limited by the plug-ins. In the present application, an Angle script is used for editing. Referring to fig. 1, a flowchart of a software automation deployment method provided by the present application is shown. As shown in fig. 1, the method includes:
101. the method comprises the steps of obtaining a front-end code of target software, wherein the front-end code comprises at least one front-end code module.
The front end is a software interface that the user can see to operate. The front-end code is program code for realizing a software interface, and the programming language of the program code is Java language. Before the software is automatically deployed, codes of all software modules are written. The software automation deployment is a process of reintegrating and compiling the written software module codes. The target software is the ultimate target of the automated deployment.
The front-end code of the target software at least comprises a front-end code module, the front-end code module can be divided according to functions, code programmers and software interfaces, and the division basis of the front-end code module is not limited in the embodiment of the application. The front-end code is selected according to the deployment purpose of the target software, and the deployment purpose can be releasing the target software, updating the target software or testing the target software.
In the application, the front-end code submission version number is identification information of the front-end code, and the front-end code of the target software, namely all front-end code modules of the front-end code of the target software, can be obtained by submitting the version number through the front-end code.
102. And acquiring a back-end code corresponding to the front-end code.
The back end refers to a software part which is responsible for processing business logic later after a user operates a software front-end interface. The front end and the back end have a specific corresponding relationship. Software deployment can be realized only if the interface of the front-end code can be realized by the back-end code, so that the back-end code corresponding to the front-end code needs to be obtained.
In the application, the front-end code corresponds to the back-end code, and the back-end code may also comprise at least one back-end code module; when the back-end code has only one back-end code module, the front-end code and the back-end code may correspond to the same back-end code no matter how many front-end code modules are included in the front-end code of the target software. The back-end code may also include a plurality of back-end code modules, and the front-end code and the back-end code may correspond in a manner that one front-end code module corresponds to one back-end code module.
In the application, the back-end code submission version number is identification information of the back-end code, and the back-end code of the target software can be acquired by submitting the version number through the back-end code.
103. And compiling the front-end code and the back-end code in parallel to respectively obtain a front-end code compiling result and a back-end code compiling result.
The front-end code and the back-end code are compiled respectively in a parallel mode and do not influence each other in the compiling process, so that the front-end code and the back-end code can be deployed independently, the deployment granularity is reduced, and the updating and deployment speed of software is accelerated. And compiling each front-end module and back-end code contained in the front-end codes in a parallel mode. In the compiling process, different code modules are compiled in parallel, so that a large amount of code compiling time is saved.
104. And merging and packing the front-end code compiling result and the back-end code compiling result into an archiving compression package.
And merging and packaging the front-end code compiling result and the rear-end code compiling result into an archiving compression package, wherein the archiving compression package is a war package. In order to facilitate program deployment, the compiling result is packaged into an archive compression package, the process is similar to the process of packaging Java class files into JAR files, relevant resources can be distributed together in a centralized mode by using a war archive file, and the war file is used as a deployment unit in the process.
105. And executing the archive compression package and deploying the target software.
And the target software is deployed, namely software codes are put into a software running environment to enable a user to use the whole workflow of the new deployment program. And executing the archiving compression package, or operating the archiving compression package, so as to achieve the purpose of automatically deploying the target software. In the application, the compiling of the front-end code, the compiling of the back-end code, the merging and packaging of the front-end and back-end compiling results and the deployment are all realized through corresponding ansable script commands, and the automation deployment is carried out by completely separating Jenkins.
According to the software automation deployment method, the Ansible script is adopted for editing, specifically, the front end code of the target software is obtained, the front end code comprises at least one front end code module, then the rear end code corresponding to the front end code is obtained, then the front end code and the rear end code are compiled in parallel, then the compiling result of the front end code and the compiling result of the rear end code are combined and packaged into a filing compression package, finally the filing compression package is executed, and the target software is deployed. Compared with the prior art, in the process of realizing software automatic deployment, due to the modular characteristic that the infrastructure supports any language compiling, related plug-ins do not need to be loaded, the compiling process is not limited by the functions of the plug-ins, the automatic deployment is easy to realize, and meanwhile, the maintenance is easy and the cost is saved. The front-end code and the back-end code are independently compiled and deployed, and the front-end code is independently compiled and deployed in a modularized mode, so that the deployment granularity is reduced, and the flexibility of software deployment is improved. The independent parallel compiling of the front-end code and the back-end code and the modularized parallel compiling of the front-end code both improve the compiling speed and improve the efficiency of software automatic deployment.
Referring to fig. 2, a flowchart of another software automation deployment method provided by the present application is shown. As shown in fig. 2, the method includes:
201. and constructing a user operation interface, and acquiring a front-end code submission version number, a rear-end code submission version number, a deployment environment parameter and a deployment operation parameter according to the user operation interface.
The user operation interface refers to the overall design of human-computer interaction, operation logic and attractive interface of software. The user operation interface is constructed based on Jenkins, and a construction platform is provided for realizing automatic deployment of software. It should be noted that, the user operation interface of the present application, a parameter selection interface designed to implement automatic software deployment, is not an interface formed after automatic deployment.
In the application, the user operation interface includes a front-end code selection menu, a back-end code selection menu, a code branch selection menu, an environment selection menu and an operation selection menu. According to the user operation interface, the front-end code submission version number, the rear-end code submission version number, the deployment environment parameter and the deployment operation parameter can be obtained.
The front-end code selection menu is used for selecting a front-end code submission version number, the front-end code submission version number is identification information of a front-end code, the rear-end code selection menu is used for selecting a rear-end code submission version number, and the rear-end code submission version number is identification information of a rear-end code. Different front-end modules and front-end codes have different front-end code submission version numbers, and the contents of the front-end codes can be searched according to the version numbers. The front-end code submits a version number, which is controlled by the version control system. The version control system can record each change of the code file and add the front-end code submission version number for each change, so that any change of the code can be traced back according to the submission of the version number of the front-end code. The version control system of the front-end code is of the type Git, SVN, etc.
The code branch menu is used for selecting code branches, wherein the code branches are all branch information obtained from a Git version library through a Groovy script. The front-end code branch and the back-end code branch are stored independently, each code branch has a plurality of nodes, and each node corresponds to a commit version number.
In the application, the method for obtaining the front-end code submission version number according to the user operation interface comprises the following steps:
the first method comprises the following steps: and acquiring the front-end code submission version number according to a front-end code selection menu of the user operation interface.
On a user operation interface, directly selecting a pull-down option in a front-end code selection menu to obtain a front-end code submission version number; each front-end code commit version number is unique.
The second method comprises the following steps: and acquiring the front-end code submission version number according to a front-end code selection menu and a code branch menu of the user operation interface.
After selecting a code branch in the code branch menu on the user operation interface, the front-end code selection menu can default to select the latest version of the front-end code submission version number as the front-end code submission version number.
Or, on the user operation interface, after selecting the code branch in the code branch menu, one front-end code submission version number in the front-end code selection menu can be selected as the front-end code submission version number according to the requirement. The front-end code commit version number is not the latest version front-end code commit version number.
The back-end code selection menu is used for selecting a back-end code submission version number, similar to the front-end code, the back-end code also has a different back-end code submission version number, and the back-end code can be searched according to the back-end code submission version number. The back-end code submits a version number, which is controlled by the version control system. The version control system can record each change of the code file and add the back-end code submission version number for each change, so that any change of the code can be traced back according to the submission of the version number of the back-end code. Similarly, the version control system of the backend code is of type Git, SVN, etc.
In the present application, the method for obtaining the submitted version number of the back-end code according to the user operation interface is similar to the method for obtaining the submitted version number of the front-end code according to the user operation interface, and specific reference is made to the above description, which is not repeated herein.
The environment selection menu is used for selecting deployment environment parameters, and the deployment environment parameters are obtained from the infrastructure environment parameter configuration file through a Groovy script. The deployment environment may include a development environment (dev), a test environment (test), a production environment (prod), and from another dimension, the deployment environment may be further divided into xx development environment, xx test environment, xx production environment, and the like according to a project occurrence location or a project attribution, which is not limited specifically herein. For example, web _ dev _ beijing, is denoted as beijing development environment, where web is an abbreviation of project, dev is an abbreviation of development environment, and beijing is a project place or a project place of ownership. In addition, test environment is abbreviated as test, and production environment is abbreviated as prod.
The operation selection menu is used to select deployment operation parameters.
202. And acquiring the front-end code of the target software according to the submitted version number of the front-end code.
The front-end code submission version number can be the latest version control system or can be manually selected by a user on a user operation interface. In the application, the front-end code is obtained according to the submitted version number of the front-end code, wherein the front-end code is in a modular design, namely the front-end code comprises at least one front-end code module.
203. And acquiring a back-end code corresponding to the front-end code according to the submitted version number of the back-end code.
And acquiring the back-end code corresponding to the front-end code according to the submitted version number of the back-end code. The back-end code corresponds to the front-end code, and the back-end code can also comprise at least one back-end code module; when the back-end code has only one back-end code module, the front-end code and the back-end code may correspond to the same back-end code no matter how many front-end code modules are included in the front-end code of the target software. The back-end code may also include a plurality of back-end code modules, and the front-end code and the back-end code may correspond in a manner that one front-end code module corresponds to one back-end code module.
204. And compiling the front-end code and the back-end code in parallel to respectively obtain a front-end code compiling result and a back-end code compiling result.
The front-end code and the back-end code are compiled in a parallel mode, and each front-end code module contained in the front-end code can also be compiled in a parallel mode to respectively obtain a front-end code compiling result and a back-end code compiling result, wherein the front-end code compiling result comprises compiling results of a plurality of front-end code modules.
If the back-end code also comprises a plurality of back-end code modules, the back-end code modules can be compiled in parallel to obtain a compiling result of the back-end code, and the compiling result of the back-end code comprises compiling results of the back-end code modules.
The front-end code and the back-end code are compiled in parallel, and the code is compiled in a modularized parallel mode, so that the compiling speed is increased, and the software automation deployment efficiency is improved.
205. And merging and packaging the front-end code compiling result and the back-end code compiling result into an archiving compression package.
In this application, when the front-end code module is a plurality of, and the back-end code module is one, it specifically does to merge and pack the front-end code compilation result and the back-end code compilation result into a filing compression package:
and directly combining and packaging the compiling results corresponding to the front-end code modules and the compiling results of the rear-end codes into an archiving compression package.
In this application, when the front end code module is N, corresponding back end code module also is N, merge the front end code compilation result and pack into filing compression package with the back end code compilation result, and N more than or equal to 2 specifically is:
merging and packaging the compiling result of the 1 st front-end code module and the compiling result of the corresponding 1 st rear-end code module to obtain a 1 st filing compression package;
and by analogy, merging and packaging the compiling result of the Nth front-end code module and the compiling result of the corresponding Nth back-end code module to obtain an Nth filing compression package.
206. And executing the archiving compression package according to the deployment environment parameters and the deployment operation parameters, and deploying the target software.
The deployment environment is obtained from the infrastructure environment parameter file through the Groovy script. The Groovy language is used without having to write too much code, while having other properties in both closed-form and dynamic languages. The deployment environment parameters also comprise information such as IP addresses, user names, passwords, preset storage positions and the like of all environment machines, so that the users do not need to remember the IP addresses of the specific deployment machines when deploying, and only need to select the deployment environment parameters. This is especially convenient when there are multiple machines in the same deployment environment. The method specifically comprises the following steps: according to the user name and the password, the archiving compression packet is stored to the preset storage position of the terminal corresponding to the IP address; stopping running the network environment of the terminal, and searching and deleting the software codes in the running directory corresponding to the filing compressed packet; decompressing the archive compression packet to the run directory; modifying a parameter configuration file of the terminal according to the deployment operation parameters; and restarting the network environment to complete the deployment of the target software. And finally, successfully deploying the target software on the terminal corresponding to the target IP address.
In the application, the unified configuration of the deployment environment can be realized, and in the process of realizing the deployment environment parameters, the configuration parameters (e.g., web _ dev, web _ test, web _ prod) are read from the configuration file to dynamically generate the deployment environment parameters. When the deployment is carried out, the IP address of a specific deployment machine is not remembered, and only the parameters of the deployment environment are selected. This is particularly convenient when there are multiple machines in a deployment environment. For example, there are two machines in a web _ prod environment.
Software deployment refers to the entire workflow of placing software code into a software runtime environment for a user to use a newly deployed program. The whole workflow generally comprises code detection, software packaging, software uploading, software release, environment parameter modification and software running environment restarting according to the execution sequence. The deployment operation may be any step in the overall workflow. The code detection is to download the software code from the version control system, and the software code may be the latest code or a certain version of software code according to the version number. Software packaging is a software package that packages software code into a specific format according to the requirements of a software operating environment, and in this application, packages the software code into a war format. Software upload is the copying of a software package onto a machine on which the software execution environment resides. Software release is the placement of a new software package into the software runtime environment. The software runtime environment herein uses a Tomcat container, and then first stops the Tomcat container, deletes the old software package in the webapps directory under the Tomcat directory, and then places the new software package in the webapps directory under the Tomcat directory. The environment parameter modification can modify the Tomcat configuration file and modify the machine IP address, which is not required to be modified every deployment and needs to be set according to the actual situation. The software running environment is restarted. Here, the Tomcat container needs to be restarted to allow the Tomcat to reload the software code for the user to access and use the software. And correspondingly generating all menu options of the operation selection menu according to the software deployment steps. The user can select the deployment operation according to the actual requirement.
According to the software automation deployment method, the Ansible script is adopted for editing, specifically, the front end code of the target software is obtained, the front end code comprises at least one front end code module, then the rear end code corresponding to the front end code is obtained, then the front end code and the rear end code are compiled in parallel, then the compiling result of the front end code and the compiling result of the rear end code are combined and packaged into a filing compression package, finally the filing compression package is executed, and the target software is deployed. Compared with the prior art, in the process of realizing software automatic deployment, due to the modular characteristic that the infrastructure supports any language compiling, related plug-ins do not need to be loaded, the compiling process is not limited by the functions of the plug-ins, the automatic deployment is easy to realize, and meanwhile, the maintenance is easy and the cost is saved. The front-end code and the back-end code are independently compiled and deployed, and the front-end code is independently compiled and deployed in a modularized mode, so that the deployment granularity is reduced, and the flexibility of software deployment is improved. The front-end code and the back-end code are compiled in parallel, and the front-end code is compiled in a modularized parallel mode, so that the compiling speed is increased, and the software automation deployment efficiency is improved.
On the basis of the method shown in fig. 1 or 2, after the target software deployment is finished, the target software may also be updated. Referring to fig. 3, a flowchart of a method for updating target software is provided. As shown in fig. 3, after the archive compression package is executed and the target software is deployed, the method further includes:
301. and acquiring the updated front-end code.
The update front-end code may refer to all front-end codes, or may refer to one or several front-end code modules.
302. And compiling the updated front-end code to obtain an updated front-end code compiling result.
303. And executing the updated front-end code compiling result, and redeploying the target software.
Similar to executing the archive compression package and deploying the target software, specifically executing the updated front-end code compilation result, and relocating the target software includes: storing the updated front-end code compiling result to the preset storage position; stopping running the network environment of the terminal, and searching and deleting the software codes in the running catalog corresponding to the front-end codes; storing the compiling result of the updated front-end code to the running directory; modifying a parameter configuration file of the terminal according to the deployment operation parameters; and restarting the network environment to complete the deployment of the target software.
And only the updated front-end code is compiled to obtain an updated front-end code compiling result, the compiling result has less content, and the target software does not need to be redeployed after compression. The front-end code deployment mode only compiling and updating is the independent deployment of the front-end code. In the process of independent compiling and independent deployment of the front-end codes, the back-end codes do not need to be recompiled, the compiling time can be saved, the time for downloading and updating the codes by the terminal is also saved, compression and decompression are not needed, and the time can be saved and the efficiency can be improved in a word. The front-end code realizes independent deployment, reduces deployment granularity and provides flexibility of software automation deployment.
Referring to fig. 4, a block diagram of a software automation deployment apparatus provided in the present application is shown. Referring to fig. 5, a block diagram of another software automation deployment device provided by the present application is shown. As a specific implementation of the method shown in fig. 1 and fig. 2, in the software automation deployment device provided by the present application, as shown in fig. 4, the editing of the device by using an anchor script by the device includes:
a first obtaining unit 41, configured to obtain a front-end code of target software, where the front-end code includes at least one front-end code module;
a second obtaining unit 42, configured to obtain a back-end code corresponding to the front-end code;
a first compiling unit 43, configured to compile the front-end code and the back-end code in parallel, and obtain a front-end code compiling result and a back-end code compiling result respectively;
a first packing unit 44, configured to merge and pack the front-end code compilation result and the back-end code compilation result into an archive compression package;
and a first deployment unit 45, configured to execute the archive compression package and deploy the target software.
Further, as shown in fig. 5, the apparatus further includes:
the constructing unit 46 is configured to construct a user operation interface before the front-end code of the target software is obtained, and obtain a front-end code submission version number, a back-end code submission version number, a deployment environment parameter, and a deployment operation parameter according to the user operation interface.
Further, as shown in fig. 5, the first obtaining unit 41 includes:
the first obtaining subunit 411 is configured to obtain a front-end code of the target software according to the front-end code submission version number;
correspondingly, the second obtaining unit 42 includes:
a second obtaining subunit 421, configured to obtain, according to the submitted version number of the back-end code, a back-end code corresponding to the front-end code;
the first deployment unit 45 includes:
the first deployment subunit 451 is configured to execute the archive compression package according to the deployment environment parameter and the deployment operation parameter, and deploy the target software.
Further, as shown in fig. 5, the deployment environment parameters include an internet protocol IP address, a user name, a password, and a preset storage location;
accordingly, the first deployment subunit 451 comprises:
a saving module 4511, configured to save the archive compression packet to the preset storage location of the terminal corresponding to the IP address according to the user name and the password;
a stopping module 4512, configured to stop running the network environment of the terminal, and search and delete the software code in the running directory corresponding to the archived compressed packet;
a decompression module 4513, configured to decompress the archive compressed packets to the run directory;
a modifying module 4514, configured to modify a parameter configuration file of the terminal according to the deployment operation parameter;
and a restart module 4515, configured to restart the network environment to complete deployment of the target software.
Further, as shown in fig. 5, the apparatus further includes:
a third obtaining unit 47, configured to obtain an updated front-end code after the archive compression package is executed and the target software is deployed;
a second compiling unit 48, configured to compile the updated front-end code to obtain an updated front-end code compiling result;
and a second deployment unit 49, configured to execute the update archive compression package, and deploy the updated front-end code.
According to the software automation deployment method, the Ansible script is adopted for editing, specifically, the front end code of the target software is obtained, the front end code comprises at least one front end code module, then the rear end code corresponding to the front end code is obtained, then the front end code and the rear end code are compiled in parallel, then the compiling result of the front end code and the compiling result of the rear end code are combined and packaged into a filing compression package, finally the filing compression package is executed, and the target software is deployed. Compared with the prior art, in the process of realizing software automatic deployment, due to the modular characteristic that the infrastructure supports any language compiling, related plug-ins do not need to be loaded, the compiling process is not limited by the functions of the plug-ins, the automatic deployment is easy to realize, and meanwhile, the maintenance is easy and the cost is saved. The front-end code and the back-end code are independently compiled and deployed, and the front-end code is independently compiled and deployed in a modularized mode, so that the deployment granularity is reduced, and the flexibility of software deployment is improved. The front-end code and the back-end code are compiled in parallel, and the front-end code is compiled in a modularized parallel mode, so that the compiling speed is increased, and the software automation deployment efficiency is improved.
In a specific implementation, the present invention further provides a terminal, including: a processor and a memory; the processor may execute the programs or instructions stored in the memory to implement some or all of the steps in the embodiments of the software automation deployment method provided by the present invention.
In specific implementation, the present invention further provides a computer storage medium, where the computer storage medium may store a program, and the program may include some or all of the steps in the embodiments of the software automation deployment method provided by the present invention when executed. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
Those skilled in the art will readily appreciate that the techniques of the embodiments of the present invention may be implemented as software plus a required general purpose hardware platform. Based on such understanding, the technical solutions in the embodiments of the present invention may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The same and similar parts in the various embodiments in this specification may be referred to each other. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the description in the method embodiment. The above-described embodiments of the present invention should not be construed as limiting the scope of the present invention.