Configure jenkins to publish php code

1, Add credentials to jenkins

First select credentials > Global > Add credentials to select users and passwords or private key
Select private key mode

2, Install SSH Plugin plug-in

When building in Jenkins, you may need to first SSH to a remote server to execute the necessary scripts, and then execute the build. At this point, you need to install the SSH Plugin plug-in

Install plug-in process:
Manage Jenkins - > Manage plugins - > SSH plug-ins (This plugin executes shell commands remotely using SSH protocol.)

Manage Jenkins --->System Configuration --> SSH remote hosts

3, Build project test php1

4, Log in to gogs account to set deployment secret key

Setup steps:
Select video version Library - > warehouse settings - > set management deployment key - > Add deployment key

Upload the test file e.txt in the video version Library:

5, Start building the test php1 project





Start building:


Console specific output information:

Success console output 
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://git@21.16.19.39:32669/gogsuser01/video.git
 > git init /data/jenkins/workspace/test_php1 # timeout=10
Fetching upstream changes from ssh://git@21.16.19.39:32669/gogsuser01/video.git
 > git --version # timeout=10
using GIT_SSH to set credentials jenkins_root.Private key
 > git fetch --tags --progress ssh://git@21.16.19.39:32669/gogsuser01/video.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url ssh://git@21.16.19.39: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://git@21.16.19.39:32669/gogsuser01/video.git # timeout=10
Fetching upstream changes from ssh://git@21.16.19.39:32669/gogsuser01/video.git
using GIT_SSH to set credentials jenkins_root.Private key
 > git fetch --tags --progress ssh://git@21.16.19.39: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: "Add to '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...
//From ssh://21.16.19.39:32669/gogsuser01/video
   4f9b5d0..8ce1d4f  master     -> origin/master
//Update 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...
//From ssh://21.16.19.39:32669/gogsuser01/video
   4f9b5d0..8ce1d4f  master     -> origin/master
//Update 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

Validation release:
Code successfully published

Tags: Linux git ssh jenkins shell

Posted on Tue, 05 May 2020 11:28:50 -0700 by deception54