Git push code actual combat

Operate according to the previous section: Simple Git server gogs construction

Start script: /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 manage 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

image

Start 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 

Check log

[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

Create a new warehouse

image

image

At the same time, you can also use commands to create warehouses

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

Push the created warehouse from the command line

[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

image

image

If you want to push automatically, you need to save the password

Password is required to retest

image.png

Modify the configuration file .git/config

[root@docker02 shell]# more .git/config 

Configure password url = http://hahashen:[email protected]:3000/hahashen/devops.git

image.png

[root@docker02 shell]# git push -u origin master

No password required

image

image.png

No way for Jenkins to pull code

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

image.png

Next study: Jenkins+Git implementation file pull and release actual combat, please scan the code to follow


image


Guess you like

Origin blog.51cto.com/15127516/2657664