配置jenkins发布php代码
一、在jenkins添加凭据
首先选择凭据-->全局-->添加凭据 可以选择用户和密码 也可以选择私钥方式
选择私钥方式
二、安装SSH Plugin插件
在Jenkins中进行构建时,可能需要首先SSH登录到一个远程服务器以执行必要的脚本,然后再执行构建。这时,需要安装SSH Plugin插件
安装插件过程:
Manage Jenkins----》Manage Plugins---->>SSH插件(This plugin executes shell commands remotely using SSH protocol.)
Manage Jenkins --->System Configuration --> SSH remote hosts
三、构建项目test_php1
四、登录gogs账户设置部署秘钥
设置步骤:
选择video版本库库--->仓库设置--->设置管理部署秘钥---->添加部署秘钥
在video版本库上传测试文件e.txt:
五、开始构建test_php1项目
开始构建:
控制台具体输出信息:
Success控制台输出 Started by user adminjk Running as SYSTEM Building in workspace /data/jenkins/workspace/test_php1 using credential 546dd19a-366e-418b-88ef-df25d0a7389f Cloning the remote Git repository Cloning repository ssh://:32669/gogsuser01/video.git > git init /data/jenkins/workspace/test_php1 # timeout=10 Fetching upstream changes from ssh://:32669/gogsuser01/video.git > git --version # timeout=10 using GIT_SSH to set credentials jenkins_root.私钥 > git fetch --tags --progress ssh://:32669/gogsuser01/video.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url ssh://:32669/gogsuser01/video.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url ssh://:32669/gogsuser01/video.git # timeout=10 Fetching upstream changes from ssh://:32669/gogsuser01/video.git using GIT_SSH to set credentials jenkins_root.私钥 > git fetch --tags --progress ssh://:32669/gogsuser01/video.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 Checking out Revision 8ce1d4f8514211f6c4fa01493969482be33e2e29 (refs/remotes/origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f 8ce1d4f8514211f6c4fa01493969482be33e2e29 # timeout=10 Commit message: "添加 ‘e.txt‘" First time build. Skipping changelog. [SSH] script: cd /data/www tar zcf /data/www/$(date "+%Y%m%d").video.tar.gz ./video cd /data/www/video/ git pull [SSH] executing... 来自 ssh://21.16.19.39:32669/gogsuser01/video 4f9b5d0..8ce1d4f master -> origin/master 更新 4f9b5d0..8ce1d4f Fast-forward e.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 e.txt [SSH] completed [SSH] exit-status: 0 [SSH] script: cd /data/www tar zcf /data/www/$(date "+%Y%m%d").video.tar.gz ./video cd /data/www/video/ git pull [SSH] executing... 来自 ssh://21.16.19.39:32669/gogsuser01/video 4f9b5d0..8ce1d4f master -> origin/master 更新 4f9b5d0..8ce1d4f Fast-forward e.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 e.txt [SSH] completed [SSH] exit-status: 0 Finished: SUCCESS
验证发布情况:
代码成功发布完成
相关推荐
pandaphinex 2020-08-09
tosim 2020-06-24
LiHansiyuan 2020-06-14
达观数据 2020-11-11
汪康 2020-10-30
ppppfly 2020-10-24
synshitou 2020-10-21
programmeryu 2020-09-24
Topbeyond 2020-08-21
lrcoop 2020-08-18
young依然 2020-08-17
oden 2020-08-16
lrcoop 2020-08-15
yserver 2020-08-15
王永迪 2020-08-15
pursuemylife 2020-08-14
leonranri 2020-07-26
CloasGao 2020-07-21