Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Svn hook (POST-COMMIT) + jenkins code launch process

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

To sum up, a svn hook through the combination of Jenkins unique features, to build this site code online architecture! Don't talk too much.

For the installation of svn and Jenkins, please see the link to the blog

Http://zzxtbl.blog.51cto.com/7620672/1744529 # svn installation

Installation of http://zzxtbl.blog.51cto.com/7620672/1656380 # jenkins

Configuration of svn hook scripts (modified under your current svn version library)

/ svn/test/hooks/post-commit

Log of REPOS= "$1" REV= "$2" LANG=en_US.UTF-8LOGFILE=/var/log/svn.log # hook script # the standard output and standard error output of the script are printed to the log file exec 1 > > "$LOGFILE" exec 2 > & 1 SVNLOOK=/usr/bin/svnlook TIME=$ (date "+% Y-%m-%d% H:%M:%S") AUTHOR=$ ($SVNLOOK author-r $REV "$REPOS") # submission Author CHANGEDDIRS=$ ($SVNLOOK dirs-changed $REPOS) # modified directory collection MESSAGE=$ ($SVNLOOK log-r $REV "$REPOS") # remarks at the time of submission Chinese # SVN client configuration is not recommended Need to modify the code root directory of * * CLIENTSVNROOT=/data/www # WEB server SVNUSER= "tiantian" SVNPASSWD= "123456" # * * function myecho () {echo "$TIME"$*"} myecho "* *"myecho" submitted version: $REV author: $AUTHOR "myecho" Note: $MESSAGE "myecho" modify directory: $(echo $CHANGEDDIRS | tr'\ n'') "MASTERDIR=$ (echo" $CHANGEDDIRS "| head-1) # CHANGEDDIRS home directory # iterate through the submitted code directory Synchronize to while on the WEB server ["$CHANGEDDIRS"! = ""] Do PROJECT=$ (echo $MASTERDIR | awk-F /'{print $1}') # determine the project folder if ["$PROJECT" = = "php"] Then myecho myecho "Project: $PROJECT synchronization directory: $MASTERDIR" myecho "synchronization $MASTERDIR to $CLIENT1:$CLIENTSVNROOT/$MASTERDIR" # password-less ssh connection to the client server Execute svn up SVN=/usr/bin/svn svn up-- non-interactive-- username $SVNUSER-- password $SVNPASSWD / $CLIENTSVNROOT/$MASTERDIR if [$?-eq 0] then / usr/bin/rsync-az-- delete $CLIENTSVNROOT/ tmp/ # temporary directory fi elif ["$PROJECT" = = "tianshi"] Then myecho myecho "Project: $PROJECT synchronization directory: $MASTERDIR" myecho "synchronization $MASTERDIR to $CLIENT2:$CLIENTSVNROOT/$MASTERDIR" svn up-- non-interactive-- username $SVNUSER-- password $SVNPASSWD / $CLIENTSVNROOT/$MASTERDIR if [$?-eq 0] then / usr/bin/rsync-az-- delete $CLIENTSVNROOT/ tmp/ # temporary directory fi else: fi # Delete the synchronized directory CHANGEDDIRS=$ (echo "$CHANGEDDIRS" | grep-v "^ $MASTERDIR") in the directory collection # get the new home directory that needs to be synchronized MASTERDIR=$ (echo "$CHANGEDDIRS" | head-1) done Don't forget to authorize chmod 755 post-commit to the hook

3. About temporary directories to grant Apache permissions and svn submission clones

Chown apache:apache-R / data/www

Chown apache:apache-R / tmp/

Chown apache:apache-R / var/log

Svn submission Clone Command

Svn co svn://192.168.40.128-username tiantian-password 123456 / data/www

Failure to operate this command will result in unauthorized submission.

2016-01-14 03:35:20 Project: php synchronization directory: php/

2016-01-14 03:35:20 synchronize php/ to: / data/www/php/

Skipped'/ data/www/php'

4. The version control layer has been written. Let's see the effect.

The creation of 5.jenkins project

There are mainly two aspects, one is source code management, and the other is to build triggers. The configuration information is as follows (* *, that is, the code is detected every minute, and if updates are found, the construction project is automatically triggered)

6. Jenkins colleagues who build data each time they perform synchronized data (rsync software synchronization)

View the results of the build

7. View test results

Summary:

Svn+jenkins builds sustainable programs. The key link of control lies in the control of svn version.

Some of the summary is very brief. Add it later. Me too, rookie. Black!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report