Automated publishing of the Web

Source: Internet
Author: User
Tags svn update

</pre> based on current business version, use of Maven and tomcat <p></p><p> if we use  jenkins release is better, but there are some problems, Just need to learn time,</p><p> based on our project, I use Python to automatically build the publishing environment </p><p> script as follows:</p><p></p>< Pre code_snippet_id= "498203" snippet_file_name= "blog_20141027_2_7484436" name= "code" class= "Python" >#!/usr/bin/ Env python#-*-coding:utf-8-*-import sysimport osimport configparserhomedir = OS.GETCWD () print homedirconfig = ConfigPa Rser. Configparser () config.read ("config.propties") user_name = Config.get ("SVN", "user_name"). Decode (' UTF8 '). Encode (' cp936 ') User_password = Config.get ("SVN", "User_password"). Decode (' UTF8 '). Encode (' cp936 ') Check_out_dir = Homedirlog_ Name = Config.get ("SVN", "Log_name"). Decode (' UTF8 '). Encode (' cp936 ') Script_dir = Homedirpkg_name=homedir+os.path.sep + "Mabaobang-web" +os.path.sep+ "target" +os.path.sep+ "Mabaobang-web.war" Rmote_ip=config.get ("SVN", "Rmote_ip") Rmote_user=config.get ("svn", "Rmote_user") rmote_passwd=config.get ("svn", "rmote_passwd")Print "Pkg_name", Pkg_namescript_dir=config.get ("svn", "Script_dir"). Decode (' UTF8 '). Encode (' cp936 ') command = "svn Log-v--xml "+ Check_out_dir +" > "+ log_name +"--username "+ user_name +"--password "+ user_passwordos.syst EM (command) os.chdir (check_out_dir) Print Os.path.abspath ("."). Decode (' cp936 '). Encode (' UTF8 ') command1= "svn update" + Check_out_dir + "--username" + user_name + "--password" + user_ Password + "--no-auth-cache--non-interactive--trust-server-cert" Os.system (Command1) os.system ("Mvn Clean:clean Package "), File_object = open (' 123123.txt ', ' W ') file_object.write (" Open 192.168.15.234\n ") file_object.writelines (" Put "+pkg_name+" \ n ") #file_object. Writelines (file.newlines) file_object.writelines (" bye\n ") #file_  Object.writelines (File.newlines) #file_object. Writelines (File.newlines) File_object.flush () File_object.close () if Os.path.exists (pkg_name): Os.chdir (homedir) try:command_sftp= "ftp.exe-l" + Rmote_user + "-PW" +rmote_passwd      + "-B 123123.txt"  Os.system (command_sftp) except exception,e:print "Done" finally:command_ssh= "SSH.EXE-SSH-PW"     + rmote_passwd + "" +rmote_passwd+ "@192.168.15.234 '/home/momabo/deploy.sh '" Os.system (COMMAND_SSH)

The configuration file is as follows:


[Svn]user_name=111111user_password=000000#check_out_dir=d:\11111\1111-parentlog_name=e:\log.log#out_put_dir=d : \1111\111-parent#war_name=d:\11111111-parent\11111111111111-web\target\111111111-web.warrmote_ip= 192.168.15.234rmote_user=xxxx
Requires two open source soft Sftp.exe Http://the.earth.li/~sgtatham/putty/0.63/x86/psftp.exe

and Ssh.exe http://the.earth.li/~sgtatham/putty/0.63/x86/plink.exe to download it.


Automating the publishing of background scripts

!/bin/bash ###, the???? of the burrow? Lou Lu Lu Lu?? The donkey recorded???. Busy # # #碌?? Lu Mao Lu he lu Lu??? Lou Lu, the eyebrow-captive?? Road cap?? The LU Lu Lu Lu?? The donkey record?? user_home=/home/3213123tomcat_home=${user_home}/tomcat# Lu Lou?? Lu?? The donkey recorded app_home=${tomcat_home}/webapps/12313123-webconf_file=${app_home}/web-inf/classes/config.propertiesip_add=. 127.0.0.1mysql_user_name=rootmysql_user_passwd=213131upload_dir=/home/312312312/upload## #碌?? Lu Mao Lu he lu Lu??? Lou Lu, the eyebrow-captive?? Road cap?? The LU Lu Lu Lu?? The donkey record??  if [!-F ${user_home}/mabaobang-web.war];then    echo-e "\033[31m error:pkg ${user_home}/mabaobang-web.war is not  exist. \033[0m "    exit 1fi### #碌? mg Lu, Lu Mao Road, magnesium Hood, ${tomcat_home}/bin/shutdown.sh#### Lou Road,????? if [!-D ${app_home}];then    ECHO-E "\033[31m Error:dir ${app_home} is not  exist. \033[0m "    exit 1else   rm-rf ${app_home}/*fimv ${user_home}/1312313-web.war ${app_home}/cd ${ TOMCAT_HOME}/WEBAPPS/M312321G-WEBJAR-XVF ${app_home}/3132133-web.war##?? Bribery?? Blind???? Recorded magnesium Dos2unix  ${conf_file}##?? Bribery?? Blind???? Recorded magnesium sed-i "s/\/\/127.0.0.1/\/\/${ip_add}/g "${conf_file}sed-i" s/^[]*jdbc_username=.*/jdbc_username=${mysql_user_name}/g "${conf_file}sed-i" s /^[]*jdbc_password=.*/jdbc_password=${mysql_user_passwd}/g "${conf_file}                                     ,         &NB Sp                          ,         &NB Sp       




Automated publishing of the Web

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.