Evolution History Of My jenkins automatic Deployment Solution

Source: Internet
Author: User
Tags jboss


Continuous integration is required for the project. It may occur several times a day and cannot be operated over and over again manually. It is natural to use automatic deployment. We selected jenkins.
I. Use plug-ins
At first I tried to use the following two plug-ins: 1. Deploy to container PluginThis plugin allows you to deploy a war to a container after a successful build.

2. Artifact Deployer Plug-inThis plug-in makes it possible to deploy artifacts from workspace to output directories.
We found that they can only deploy a single jar/war/ear at a time, and our project has at least hundreds of jar files, which will continue to increase in the future, which cannot meet our needs.

Ii. Use custom scripts
Because all jar and war files follow the naming conventions, I can use scripts to retrieve these jar files and then automatically deploy them as needed. The script is as follows:
1. Deploy a single

@ Echo offset jboss_path = E: \ gxpt-jboss-1.0set project_name = % WORKSPACE % \ target \ % JOB_NAME %-% 1.% 2 if exist % project_name % (echo % BUILD_ID % -- deploying % project_name % copy/y % project_name % jboss_path % \ server \ default \ deploy \) else (echo % BUILD_ID % -- % project_name % not found)


This method achieves the same effect as the plug-in.
2. Deploy multiple
@ Echo off & setlocal EnableDelayedExpansionset jboss_path = E: \ gxpt-jboss-1.0set project_sn = % 1 set project_default = % jboss_path % \ server \ default _ % project_sn % \ deploy \ set project_home = % JENKINS_HOME % set project_tmp = % project_home % \ tmp _ % project_sn % set workspace = % project_home % \ workspaceif not exist % project_tmp % md % project_tmp % echo [% BUILD_ID %] retrieving all jar packages and war packages to % project_tmp % temporary directory for/r "% workspace %" % I in (gx Pt_common _*. jar) do (echo is copying % I to % project_tmp % \ copy/y "% I" % project_tmp % \) for/r "% workspace %" % I in (gxpt _ * _ % project_sn % *.? Ar) do (echo is copying % I to % project_tmp % \ copy/y "% I" % project_tmp % \) echo [% BUILD_ID %] to complete the copy. Echo ------------------------------------------------ echo ------------------------------- echo starts automatic deployment ...... Echo export echo --------------------------------- echo [% BUILD_ID %] is being deployed. % project_sn % entity jarfor/r % project_tmp % I in (gxpt_entity _ % project_sn %. jar) do (echo is deploying % I to % project_default % copy/y "% I" "% project_default % ") echo ------------------------------------------------ echo ------------------------------- echo [% BUILD_ID %] The jarfor/r % project_tmp % of commontool is being deployed. % I in (gxpt_common_tool.jar) do (echo is deploying % I to % project_default % copy/y "% I" "% project_default % ") echo export echo --------------------------------- echo [% BUILD_ID %] The commonEao interface jarfor/r % project_tmp % I in (gxpt_common_eao.jar) is being deployed) do (echo is deploying % I to % project_default % copy/y "% I" "% project_default %") echo ------------------------------------------------ ec Ho ------------------------------- echo [% BUILD_ID %] deploying commonEao implementation jarfor/r % project_tmp % I in (gxpt_common_eao_impl.jar) do (echo is deploying % I to % project_default % copy/y "% I" "% project_default % ") echo response echo --------------------------------- echo [% BUILD_ID %] The mgr layer interface jarif exist interface.txt del interface.txt for/r % project_tmp % I in (gxp T_mgr _ % project_sn % _*. jar) do (echo "% I" | find "impl"/I> interface.txt set "zer = % I" for/f "delims =. "% j in (interface.txt) do (set" zer = null ") if not "! Zer! "=" Null "(echo is deploying % I to % project_default % copy/y" % I "" % project_default % ")) if exist interface.txt del interface.txt echo export echo --------------------------------- echo [% BUILD_ID %] is deploying mgr layer of % project_sn % to implement jarfor/r % project_tmp % I in (gxpt_mgr _ % project _ _ * _ impl. jar) do (echo is deploying % I to % project_default % copy/y "% I" "% project_default %") echo --------- Export echo --------------------------------- echo [% BUILD_ID %] warfor/r % project_tmp % I in (gxpt_web _ % project_sn % _*. war) do (echo is deploying % I to % project_default % copy/y "% I" "% project_default % ") echo ------------------------------------------------ echo ------------------------------- echo [% BUILD_ID %] % project_sn % the project has been deployed.



It can be found that this script depends on strict naming conventions, otherwise it will be meaningless. At the same time, it also has great limitations. If it is a third-party package (not based on naming conventions), this script will add a special part to handle these "exception" packages, it will make scripts more complex, not easy to maintain and expand, and the retrieval efficiency is low.
3. Improved Script: Add a sequence file to maintain the deployment content and sequence.
Instead of writing complex syntaxes and searching by name, it is better to maintain the order of packages and packages to be deployed through a file.
Gxpt_entity_qxgxpt_common_tool ...... Omit gxpt_mgr_qx_organizationgxpt_mgr_qx_operation_impl ...... Gxpt_web_qx_authorizegxpt_web_qx_modulegxpt_web_qx_operation ...... Omitted
Script:
@ Echo off & setlocal EnableDelayedExpansionset jboss_path = Y: set project_sn = % 1 set project_default = % jboss_path % \ default-% project_sn % \ deploy \ set project_home = D: \ Jenkinsset project_tmp = % project_home % \ tmp _ % project_sn % set project_workspace = % project_home % \ workspaceset workspace = % project_workspace % \ gxpt _ % project_sn % _ mainif not exist % project_tmp % md % project_tmp % echo [% BUILD_ID %] retrieving all jar packages and war packages to % project_t Mp % temporary directory echo ------------------------------- echo --------------------- for/f % I in (% WORKSPACE % \ % project_sn1__deploy_sequence.txt) do (if exist "% project_workspace % \ % I \ target \ % I. jar "(echo is copying % I to % project_tmp % \ copy/y" % project_workspace % \ % I \ target \ % I. jar "% project_tmp % \) for/f % I in (% WORKSPACE % \ % project_sn1__deploy_sequence.txt) do (if exist "% project_workspace % \ % I \ target \ % I. war "(echo Copying % I to % project_tmp % \ copy/y "% project_workspace % \ % I \ target \ % I. war "% project_tmp % \) echo --------------------------------- echo --------------------- echo [% BUILD_ID %] to complete the copy. Echo ------------------------------------------------ echo ------------------------------- echo starts automatic deployment ...... Echo export echo ------------------------------- for/f % I in (% WORKSPACE % \ % project_sn1__deploy_sequence.txt) do (if exist "% project_tmp % \ % I. jar "(echo is deploying % I to % project_default % copy/y" % project_tmp % \ % I. jar "" % project_default % ") for/f % I in (% WORKSPACE % \ % project_sn1__deploy_sequence.txt) do (if exist" % project_tmp % \ % I. war "(echo is deploying % I to % project _ Default % copy/y "% project_tmp % \ % I. war "" % project_default % ") echo -------------------------------------------------- echo ----------------------------- echo [% BUILD_ID %] % project_sn % the project has been deployed.


The advantage is that you do not need to maintain complex scripts, add or delete packages, and change the deployment sequence. You only need to modify the sequence file. This script is common and direct to the target, it can also achieve good efficiency.

3. Why didn't we use the ear
We have considered putting all the packages together into one ear, which brings us an advantage: during deployment, we only need to deploy one ear package. It seems perfect, but it also has its limitations:
1. In the development environment, our developers develop a single package, and a simple test requires an ear, which is troublesome. 2. We need to modify the spring files of all web projects to ensure that they can find the ejb components. 3. The deployment flexibility is lost. Our ejb components require flexible deployment, if they are all in one ear, it means they can only be on one machine.
After the project is launched, we can use the ear method in the production environment and then work with the jboss cluster. However, in the development environment, we still choose not to use the ear.
Iv. Custom Script + disk ing
We can see that using scripts, we can only complete local deployment. If plug-ins are used or cargo is used, remote deployment can be completed, but only one can be deployed at a time. What should I do?
Windows shared directory + disk ing. It seems very simple, but this raises another problem. In the case of screen lock, the disk is disconnected during disk ing. We use the win8 Server, so it is impossible to keep the user connection all the time, or even the display may be lost later. If you keep the disk ing connection continuously, it becomes a difficult problem. Fortunately, google

Use this at your own risk. (I have tested it on XP and Server 2008x64 R2)

For this hack you will need SysinternalsSuite by Mark Russinovich:

Step one: Open an elevated cmd.exe prompt (Run as administrator)

Step two: Elevate again to root using unzip xec.exe: Navigate to the folder containing SysinternalsSuite and execute the following commandpsexec -i -s cmd.exeYou are now inside of a prompt that isnt authority\systemAnd you can prove this by typingwhoami.-iIs needed because drive mappings need to interact with the user

Step Three: Create the persistent mapped drive as the SYSTEM account with the following commandnet use z: \\servername\sharedfolder /persistent:yes

It's that easy!

WARNING: You can only remove this mapping the same way you created it, from the SYSTEM account. If you need to remove it, follow steps 1 and 2 but change the command on step 3net use z: /delete.

NOTE: The newly created mapped drive will now appear for ALL users of this system but they will see it displayed as "Disconnected Network Drive (Z :)". do not let the name fool you. it may claim to be disconnected but it will work for everyone. that's how you can tell this hack is not supported by M $.


Following the steps above, we have solved this problem and implemented automatic remote deployment of multiple packages.

Currently, we use solution 4 to meet your needs. If you have a better solution, please feel free to advise.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.