按上节操作:简易Git服务器gogs的搭建
启动脚本:/usr/local/gogs/start.sh
[root@docker02 ~]# more /usr/local/gogs/start.sh
#!/bin/bash
/usr/local/gogs/gogs web > /tmp/gogs.log 2>&1
[root@docker02 ~]# chmod +x /usr/local/gogs/start.sh
systemctl管理gogs
[root@docker02 ~]# more /usr/lib/systemd/system/gogs.service
[Unit]
Description=gogs
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/gogs/start.sh
User=root
[Install]
WantedBy=multi-user.target
启动gogs
[root@docker02 ~]# systemctl restart gogs
[root@docker02 ~]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 7091/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6846/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7133/master
tcp6 0 0 :::22 :::* LISTEN 6846/sshd
tcp6 0 0 :::3000 :::* LISTEN 7396/gogs
tcp6 0 0 ::1:25 :::* LISTEN 7133/master
查日志
[root@docker02 ~]# tail -f /usr/local/gogs/log/gogs.log
2021/01/13 08:21:37 [ INFO] Gogs 0.11.86.0130
2021/01/13 08:21:37 [ INFO] Cache Service Enabled
2021/01/13 08:21:37 [ INFO] Session Service Enabled
2021/01/13 08:21:38 [ INFO] Git Version: 1.8.3.1
2021/01/13 08:21:38 [ INFO] SQLite3 Supported
2021/01/13 08:21:38 [ INFO] Run Mode: Production
2021/01/13 08:21:38 [ INFO] Listen: http://0.0.0.0:3000
创建新的仓库
同时也可以用命令创建仓库
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin http://192.168.20.40:3000/hahashen/devops.git
git push -u origin master
从命令行推送已经创建的仓库
[root@docker02 ~]# mkdir -pv /soft/shell
[root@docker02 ~]# cd /soft/shell/
[root@docker02 shell]# ll
total 0
[root@docker02 shell]# git init
[root@docker02 shell]# vim hahage.sh
[root@docker02 shell]# git add *
[root@docker02 shell]# git commit -m hahashen
[root@docker02 shell]# git remote add origin http://192.168.20.40:3000/hahashen/devops.git
[root@docker02 shell]# git push -u origin master
如要自动推送,需要把密码保存
重新测试需要输入密码
修改配置文件.git/config
[root@docker02 shell]# more .git/config
配置密码url = http://hahashen:123456@192.168.20.40:3000/hahashen/devops.git
[root@docker02 shell]# git push -u origin master
不需输入密码
无Jenkins拉取代码的方式
git clone http://192.168.20.40:3000/hahashen/devops.git
[root@docker02 ~]# cd /tmp/
[root@docker02 tmp]# git clone http://192.168.20.40:3000/hahashen/devops.git
[root@docker02 tmp]# cd devops/
[root@docker02 devops]# ll
total 8
-rw-r--r-- 1 root root 14 Jan 13 08:59 hahage.sh
-rw-r--r-- 1 root root 15 Jan 13 08:59 hahashen.sh
接下来学习:Jenkins+Git实现文件的拉取下发实战,请扫码关注