Jenkins发布PHP项目之一自动化部署
开始构建项目
新建—输入项目名称php-deploy,选择构建自由风格的软件项目—下一步
Gernal配置,丢弃旧的构建,防止jenkins构建较多之后变臃肿
配置好源码管理之后可以直接先保存构建一次
下面这个能跑通的前提是用户已经打通Credentials
手动在Jenkins主机上切换到Jenkins用户,执行git命令拉取代码
sudo su -s /bin/bash jenkins
git clone git@10.211.55.3:/home/git/repos/app.git
我这里通过rpm安装的Jenkins 所以将
/var/lib/jenkins/.ssh/id_rsa.pub追加到/home/git/.ssh/authorized_keys里面
一般就OK了
关于凭据这里配置了Jenkins用户
关于凭据说明参考此图
只有上面条件OK之后,下面源码管理这里才不会出错
然后直接构建
然后点击最左侧的图标:
查看控制台输出:
Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/php-deploy
The recommended git tool is: NONE
using credential 73d0c28a-8320-4393-86eb-2b60472899a1
Cloning the remote Git repository
Cloning repository git@10.211.55.3:/home/git/repos/app.git> /usr/bin/git init /var/lib/jenkins/workspace/php-deploy # timeout=10
Fetching 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 config remote.origin.url git@10.211.55.3:/home/git/repos/app.git # timeout=10> /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a (refs/remotes/origin/master)> /usr/bin/git config core.sparsecheckout # timeout=10> /usr/bin/git checkout -f 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a # timeout=10
Commit message: "add php file"
First time build. Skipping changelog.
[php-deploy] $ /bin/sh -xe /tmp/jenkins6495258260213274036.sh
Finished: SUCCESS
到现在为止,说明数据的拉取是正常的。都可以到对应的目录里边来查看。
# pwd
/var/lib/jenkins/workspace/php-deploy
# ls
index2.html index3.html index.html phpinfo.php
下一步的操作就是将拉渠道的代码推送到对应的PHP服务器的对应目录/home/www
命令简单说明:因为这个是在root下执行的,所以需要配置root用户的免密登陆
将Jenkins 的root用户的id_rsa.pub放到
cat /root/.ssh/id_rsa.pub >> /home/www/.ssh/authorized_keys
源目录删除的文件,目标文件也要删除,加--delete参数--delete delete extraneous files from destination dirs
--progress show progress during transfer
rsync -raz --delete --progress * www@10.211.55.3:/home/www
配置中如下填写
再次构建,控制台输出
Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/php-deploy
The recommended git tool is: NONE
using credential 73d0c28a-8320-4393-86eb-2b60472899a1> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository> /usr/bin/git config remote.origin.url git@10.211.55.3:/home/git/repos/app.git # timeout=10
Fetching 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=10
Checking out Revision 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a (refs/remotes/origin/master)> /usr/bin/git config core.sparsecheckout # timeout=10> /usr/bin/git checkout -f 8d2821c2b9e4ac77d758ba2ca6ad87bc9a7e709a # timeout=10
Commit 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 list
Finished: SUCCESS
登录到PHP服务器,可以看到文件已经存在了
$ pwd
/home/www
$ ls
index2.html index3.html index.html phpinfo.php
Jenkins发布PHP项目之一自动化部署相关推荐
- 利用Jenkins实现JavaWeb项目的自动化部署
修改代码,打包,上传,重启... 大把的时间花费在这些重复无味的工作上.笔者与当前主流的价值观保持一致:我们应该把时间花费在更有意义的事情上.我们可以尝试借助一些工具,让这些重复机械的工作交给计算机去 ...
- Java利用jenkins做项目的自动化部署
本地的jekins密码 2722e8ea873b4cf08884c22dff732bab 这篇文章主要介绍了Java利用jenkins做项目的自动化部署,小编觉得挺不错的,现在分享给大家,也给大家做个 ...
- AWS DevOps – 配合Jenkins和CodeDeploy实现代码自动化部署
AWS DevOps – 配合Jenkins和CodeDeploy实现代码自动化部署 Amazon ElastiCache 连接至 Redis 节点 通过 AWS Command Line Inter ...
- 夕阳桥断 Linux(centos6.5)下安装jenkins Jenkins 的前身是 Hudson 是一个可扩展的持续集成引擎。 通俗的来讲,jenkins就是一个可以实现自动化部署的一个插
夕阳桥断 Linux(centos6.5)下安装jenkins Jenkins 的前身是 Hudson 是一个可扩展的持续集成引擎. 通俗的来讲,jenkins就是一个可以实现自动化部署的一个插件, ...
- (二)jenkins+bonobo git server+windows系统自动化部署springboot项目(自动化部署)
前提:jenkins安装 参考:(一)jenkins+bonobo git server+windows系统自动化部署springboot项目(jenkins安装) 1插件下载 主要是检查如下插件是否 ...
- Jenkins结合Gitee(码云)自动化部署Springboot项目(比较详细)
Jenkins结合码云自动化部署Springboot项目 一.准备工作(有的话,可以忽略) 1. 安装wget 2. 安装jdk 3. 安装maven 4. 安装git 二.开始部署 (jenkins ...
- 基于docker jenkins nginx gitee实现前端自动化部署
部署对比 手动部署 平时我们在上线一个新项目的时候,可能需要先执行打包指令,然后登录服务器,将dist包丢到服务器nginx/html的文件下,看似很简单,但是当项目频繁迭代,一直重复性的操作也是很浪 ...
- jenkins修改pom文件_自动化部署—Jenkins+Docker构建工程
================= 交作业:hello-world级的自动化部署(Maven+Git+Docker+Jenkins),因为内容稍微有点儿多,分两篇,这是第二篇--构建工程. ===== ...
- 利用gitee仓库的流水线功能实现Java项目的自动化部署
背景:因为之前每次写完新的BUG之后,需要手动打包然后传到服务器,再进行启动,整个过程太浪费时间,而且没有一点技术含量,所以想做自动化部署. 本次自动化部署采用了gitee退出的仓库流水线功能,可以帮 ...
最新文章
- js不停地触发按钮的事件
- 200G vs 400G:谁是数据中心网络下一站?
- LeetCode Design TinyURL
- kubectl 命令管理(1)
- linux-RPM与YUM
- 巧用Dictionary实现日志数据批量插入
- Spark入门(二)多主standalone安装
- NFS网络共享文件系统
- 易语言不用oracle客户端_大叔学中文编程之易语言02
- Android 中View仅仅能接收到ACTION_DOWN无法接收ACTION_MOVE和ACTION_UP解决的方法
- 阿里云云计算 52在线实验--云监控初体验
- linux df命令无反馈,Linux df 命令长时间没有返回
- Qt 串口数据采集并绘图
- 一般小型网站价格,小型网站怎么优化
- 看图工具、测试移动端
- 简单的局域网直播方案(OBS+Smart_rtmpd)
- 蝉知门户系统迁移到SAE平台-对蝉知2.5版本部分功能的限制
- 力扣杯-竞赛合集-LCP 02. 分式化简
- Design Compiler NXT:RTL Synthesis Workship (1)DC流程概述
- Android版本第五人格,第五人格九游版