Operations 4 min read

Quick Guide to Sync Code from GitHub via a Middle Machine and Deploy with Jenkins

This article explains how to obtain required permissions, add SSH keys, create a shell deployment script using git and rsync, and configure Jenkins to automatically deploy code from GitHub through a middle machine to a test server.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Quick Guide to Sync Code from GitHub via a Middle Machine and Deploy with Jenkins

Recently the project code was migrated to Git, requiring changes to the test environment deployment; because the test server lacks direct Git access, a middle machine is used as a relay.

First, necessary permissions are obtained: test server ↔ middle machine, Jenkins server ↔ middle machine, and rsyncd.conf is configured on the test server to allow file transfer.

1. Add SSH Key – Install Git on the middle machine, generate an SSH key with ssh-keygen -t rsa , and add the public key to the Git platform.

2. Maintain Shell Script – Write a script (e.g., /home/xxx/shell/deploy.sh ) that clones the repository ( git clone git-ssh-url /home/xxx/git/test/ ), pulls code, and uses rsync to sync files to the test server, optionally excluding specific configuration files.

The script accepts a branch name as a parameter (e.g., sh test qtest branch_001 ) to deploy a specific branch to the test server; it can be adapted for multiple test servers.

3. Jenkins Configuration – Add the necessary certificates and SSH sites so that the Jenkins server can reach the middle machine, then create a job that runs the deployment script.

After saving the Jenkins job, the environment can be deployed automatically.

deploymentDevOpsgitrsyncJenkinsshell script
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.