所須要用到的環境:node
Gitlab: 172.20.7.70 Jenkins: 172.20.7.71 nginx: 172.20.7.72
gitlab 和Jenkins安裝自行百度nginx
首先經過網頁訪問nginx,nginx默認測試頁我是改了的 ,因此看到的不是它原生的git
一、先在Jenkins機器上建立好ssh密鑰對dom
[root@node2 ~]#ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Tkn6vspyZyn5QUwyISsLNIA6zVmo06iZVMmNZf+HprI root@node2.dklwj.com The key's randomart image is: +---[RSA 2048]----+ |+o..*o. | |o o=o+.. | |o*oo. o.o | |*o=o B... | |o=. . S+ . | |+ =o . | | . o+. | | ..*.+. | | Eo*+. | +----[SHA256]-----+
二、查看公鑰文件ssh
[root@node2 ~]#cat /root/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvWyCl1WXHHrPHwUNgvx3BvMNhd5mbNlJz75gAtdm0ff+a6hr4eOm2ajHMONNQq7h2QdrVqi+o+OYYK7PFfLAxmKjWYlwEdz/3J1UeclTBQKAungiazYOBVGHqL6Omhm4kdljkTP0BljgApuJD1KHm0AisJ9bDJk7YTUXhrdF53ThVaPXIDkrsBi4a+D6dnWsopCXweadoLe9qHt26yPGHAzPjlCG6qL5c7oMFBdaG5sL4iMqw9fudbkZ8q3sv+CN0brTS1uM8MtfAjnaVGHVlBHjZOOLg5WcqIvE1LSONQSyElN7xvc/mYAGErOnhyGny0QE/R1WgbMFKrT5OB59z root@node2.dklwj.com
三、經過網頁打開gitlab的操做界面
四、驗證自動拉取是否成功ide
五、在Jenkins上配置ssh私鑰gitlab
六、新建任務,須要提早在Jenkins主機把ssh免密鑰文件複製到nginx主機上去測試
[root@node02 ~]#ssh-copy-id root@172.20.7.72
七、經過Jenkins構建以後再次訪問nginx頁面3d