配置jenkins發佈php代碼

一、在jenkins添加憑據

首先選擇憑據-->全局-->添加憑據 可以選擇用戶和密碼 也可以選擇私鑰方式
選擇私鑰方式
配置jenkins發佈php代碼

二、安裝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
配置jenkins發佈php代碼

三、構建項目test_php1

配置jenkins發佈php代碼

四、登錄gogs賬戶設置部署祕鑰

配置jenkins發佈php代碼

設置步驟:
選擇video版本庫庫--->倉庫設置--->設置管理部署祕鑰---->添加部署祕鑰
配置jenkins發佈php代碼

在video版本庫上傳測試文件e.txt:
配置jenkins發佈php代碼

五、開始構建test_php1項目

配置jenkins發佈php代碼
配置jenkins發佈php代碼
配置jenkins發佈php代碼
配置jenkins發佈php代碼
配置jenkins發佈php代碼

開始構建:
配置jenkins發佈php代碼
配置jenkins發佈php代碼
配置jenkins發佈php代碼

控制檯具體輸出信息:

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://[email protected]:32669/gogsuser01/video.git
 > git init /data/jenkins/workspace/test_php1 # timeout=10
Fetching upstream changes from ssh://[email protected]:32669/gogsuser01/video.git
 > git --version # timeout=10
using GIT_SSH to set credentials jenkins_root.私鑰
 > git fetch --tags --progress ssh://[email protected]:32669/gogsuser01/video.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url ssh://[email protected]: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://[email protected]:32669/gogsuser01/video.git # timeout=10
Fetching upstream changes from ssh://[email protected]:32669/gogsuser01/video.git
using GIT_SSH to set credentials jenkins_root.私鑰
 > git fetch --tags --progress ssh://[email protected]: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

驗證發佈情況:
代碼成功發佈完成
配置jenkins發佈php代碼
配置jenkins發佈php代碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章