Build Jenkins + Maven + Git to realize automatic project deployment

1. Install Git

(1) Execute the installation command

	yum install git

Insert picture description here
(2) View git installation results

		git --version

Insert picture description here

(3) View installation information

	Git默认安装在/usr/libexec/git-core目录下,可输入指令,查看安装信息:

Insert picture description here

2. Install maven

	***可在官网下载指定版本 http://mirror.bit.edu.cn/apache/maven

Insert picture description here
(1) Unzip

	tar -zxvf apache-maven-3.5.4-bin.tar.gz 

(2) Configure maven environment variables

	vi /etc/profile

(3) Add environment variables

	export MAVEN_HOME=/var/local/apache-maven-3.5.4
	export MAVEN_HOME
	export PATH=$PATH:$MAVEN_HOME/bin

Insert picture description here
(4) Execute the command to make the maven environment variable take effect,

	source /etc/profile

(5) View the maven installation status

	mvn -v

Insert picture description here

3. Configure git ssh key

Jenkins native deployment can directly execute the corresponding script, such as cross-machine deployment project requires the following three steps

	1.需要通过公共秘钥连通两个机器
	2. 修改部署机器下的.ssh目录权限问题
	3. 脚本执行(根据部署环境不同,自己编写脚本)

Connected machine:
1>Generate the secret key on the machine (4.19) where Jenkins is deployed, and execute the following command:

	ssh-keygen -t rsa -C "[email protected]"

Insert picture description here
Two files id_rsa will be generated in the .ssh directory, id_rsa.pub
Insert picture description here
2> assign the content of the id_rsa.pub file generated by the machine (4.19) to
the authorized_keys file in the .ssh directory of the machine to be deployed (4.125)

3>After completion, you need to execute a line of command on the 4.19 machine [ssh Deploy Machine User@Deploy Machine ip]

Modify the permissions of the .ssh directory

  1. The permissions of the .ssh directory must be 700
  2. .ssh/authorized_keys file permissions must be 600

Script execution (for reference only)

Insert picture description here
.
.
.
Afterword: After I found out that my white shoes were dirty, my partner would brush me clean, so I decided to buy only white shoes from now on.

Guess you like

Origin blog.csdn.net/weixin_43945983/article/details/106134864