Linux uses Git and gradle to compile the project and write a simple automatic publishing script __linux

Source: Internet
Author: User
Tags api manual mkdir parent directory ssh git clone

[TOCM] install git and deploy public key install sudo yum install git linux create SSH key
Ssh-keygen-t rsa-c "xxxxx@xxxxx.com" #使用邮箱创建 view public key Cat ~/.ssh/id_rsa.pub execute the following command to add the public key to the Git@osc
Ssh-t git@git.oschina.net
But there may be Permission denied (PublicKey). Situation (temporarily do not know why), you can only manually add the public key to the Git@osc above the synchronization github to the local

Clone project to local
git clone git://github.com:xxxx/test.git # #以gitreadonly方式克隆到本地, only can read
git clone git@github.com:xxx/ Test.git  # #以SSH方式克隆到本地, can read and write, and will initialize the warehouse by default by project name
git clone https://github.com/xxx/test.git # #以https方式克隆到本地, can read and write
git fetch git@github.com:xxx/xxx.git  # #获取到本地但不合并
git pull git@github.com:xxx/xxx.git # #获取并合并内容到本地, It's going to go into the project,

like I want to sync Master branch to local
git pull git@git.oschina.net:youname/xx.git master Master
Install GradleInstall the JDK and configure the Java_home environment variables. Because Gradle is written in groovy, groovy is based on Java. In addition, the Java version is either less than 1.5. Download. The address is: Http://www.gradle.org/downloads. Download the version you want here. Extract. If you are downloading a full package of gradle-xx-all.zip, it will have the following content:
Binary user manual (including PDF and HTML two versions) DSL Reference Guide API manual (including Javadoc and Groovydoc) sample source code for reference purposes only.

4, configure environment variables. Configure gradle_home into your Gradle root directory, and then add%gradle_home%/bin (Linux or Mac $gradle_home/bin) to the PATH environment variable.

Vim/etc/profile
    #在文件最后添加
    export java_home=/home/hadoop/app/jdk1.7.0_65
    export gradle_home=/home/ Hadoop/app/gradle
    export path= $PATH: $JAVA _home/bin: $GRADLE _home/bin
    -------------------
    #刷新配置
    Source/etc/profile

After the configuration is complete, run gradle-v and check to see if the installation is correct. If installed correctly, it prints out the Gradle version information, including its build information, Groovy, Ant, Ivy, current JVM, and current system version information. compiling projects using Gradle

# Build the entire project first, need to download lib dependencies etc
gradle build-x Test
# In the war package, compile the project default under the Web module under the build/libs under
gradle war-x test

Ability to write Gradle scripts to automatically package and then copy and delete files write Linux scripts automatically packaged and published

ECHO-E the "Mrcode Automation deployment Script" Project_name= "You-0.1-snapshot" #名称 the name is used by default as the parent directory of the publishing project dir_release_webapps=/xxxxx/release/ WebApps # Project Publishing directory dir_release_backup_project=/xxxxx/release/backup/$PROJECT _name #项目备份 dir_release_temp_project=/ xxxxx/release/temp/$PROJECT _name #发布前对项目做的临时操作目录 dir_git_project=/xxxxx/git/gitosc/you #项目源码所在目录 file_git_project_  war=/xxxxx/git/gitosc/xxx/you/build/libs/$PROJECT _name.war # The path where the war package was compiled dir_tomcat=/xxxxx/apache-tomcat-7.0.65
        #tomcat根目录 echo "============ to handle whether a given working directory exists and does not exist, create" if [-D "$DIR _release_webapps"]; Then echo $DIR _release_webapps "directory exists already in" Else mkdir-p $DIR _release_webapps fi if [
        -D "$DIR _release_backup_project"]; Then echo $DIR _release_backup_project "directory exists already in" Else mkdir-p $DIR _RELEASE_BACKUP_PR
        Oject fi if [d "$DIR _release_temp_project"]; Then echo $DIR _release_temp_project "directory exists already in" Else mkdir-p $DIR _releAse_temp_project fi echo "============ Pull Sync Update project" CD $DIR _git_project GIT pull Git@git.oschina.net:youname/you.git ER master gradle war-x test echo "============ prepare project file" Cp-u $FILE _git_project_war $DIR _release_temp_project cd $DIR _r Elease_temp_project jar-xvf $PROJECT _name.war # 1.war Packet decompression RM-RF $PROJECT _name.war while [0]; Do echo-e "============ need to stop the Tomcat service. And will perform the following steps: "ECHO-E" 1. Stop all Tomcat services on this machine "ECHO-E" 2. To back up the old project directory "ECHO-E" 3.copy project files to the Publish directory echo- E "4. Start the Tomcat service" Read-p "please decide whether to automate the above steps (y/n):" Isautosv if ["$isAutoSv" = "n"]; Then exit 0 elif ["$isAutoSv" = "Y"]; Then break fi do echo-e "= = 1. Stop TOMCAT service ... "$DIR _tomcat/bin/shutdown.sh ps-ef | grep root | grep Tomcat | Grep-v grep | Cut-c 9-15 | Xargs kill-s 9 Echo-e "= = 2. Back up the old version directory ... "MV $DIR _release_webapps/$PROJECT _name $DIR _release_backup_project/$ (date +%y%m%d%h%m) echo-e" = = 3. Copy project file to publish directory ... "MV $DIR _release_temp_project $DIR _Release_webapps echo-e "= = 4. Start the TOMCAT service $DIR _tomcat/bin/startup.sh

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.