Jenkins发布PHP项目之一自动化部署( 二 )


命令简单说明:因为这个是在root下执行的 , 所以需要配置root用户的免密登陆
将Jenkins 的root用户的id_rsa.pub放到
cat /root/.ssh/id_rsa.pub >> /home/www/.ssh/authorized_keys
源目录删除的文件 , 目标文件也要删除 , 加--delete参数 --deletedelete extraneous files from destination dirs--progressshow progress during transferrsync -raz --delete --progress * www@10.211.55.3:/home/www配置中如下填写
Jenkins发布PHP项目之一自动化部署文章插图
再次构建,控制台输出
Started by user adminRunning as SYSTEMBuilding in workspace /var/lib/jenkins/workspace/php-deployThe recommended git tool is: NONEusing credential 73d0c28a-8320-4393-86eb-2b60472899a1 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > /usr/bin/git config remote.origin.url git@10.211.55.3:/home/git/repos/app.git # timeout=10Fetching upstream changes from git@10.211.55.3:/home/git/repos/app.git > /usr/bin/git --version # timeout=10 > git --version # 'git version 1.8.3.1'using GIT_SSH to set credentials> /usr/bin/git fetch --tags --progress git@10.211.55.3:/home/git/repos/app.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10Checking out Revision 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a (refs/remotes/origin/master) > /usr/bin/git config core.sparsecheckout # timeout=10 > /usr/bin/git checkout -f 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a # timeout=10Commit message: "add php file" > /usr/bin/git rev-list --no-walk 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a # timeout=10[php-deploy] $ /bin/sh -xe /tmp/jenkins5178794915886016847.sh+ rsync -raz --delete --progress index2.html index3.html index.html phpinfo.php www@10.211.55.3:/home/www/______(o o)(o o) (V) ALex CentOS (V)--m-m-----------------m-m--sending incremental file listFinished: SUCCESS登录到PHP服务器 , 可以看到文件已经存在了
【Jenkins发布PHP项目之一自动化部署】$ pwd/home/www$ lsindex2.htmlindex3.htmlindex.htmlphpinfo.php


推荐阅读