Files
2025-12-04 09:12:56 +08:00

256 lines
7.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# gitea
### 安装
下载
[Releases · go-gitea/gitea](https://github.com/go-gitea/gitea/releases)
安装的前提必须要 `PATH` 里面有 git
> Check that Git is installed on the server. If it is not, install it first.
#### 二进制安装
```bash
cd /data01/devops/gitea
wget -O gitea https://dl.gitea.io/gitea/1.12.2/gitea-1.12.2-linux-amd64
https://github.com/go-gitea/gitea/releases/download/v1.12.2/gitea-1.12.2-linux-amd64.xz
xz -d gitea-1.12.2-linux-amd64.xz
mv gitea-1.12.2-linux-amd64 gitea
./gitea web
nohup ./gitea web > log.file 2>&1&
第一次打开页面的时候会配置数据库登信息
第一个注册的用户为管理员
管理员账户为rootadmin被系统保留无法使用
点击【立即安装】后会开始在数据库建表时间有点长一共74张表
```
**官网还有更正规的安装方式**,英文的详细一些
[从二进制安装 - Docs](https://docs.gitea.io/zh-cn/install-from-binary/)
[Installation from binary - Docs](https://docs.gitea.io/en-us/install-from-binary/)
### docker 安装
[使用 Docker 安装 - Docs](https://docs.gitea.io/zh-cn/install-with-docker/)
[Installation with Docker - Docs](https://docs.gitea.io/en-us/install-with-docker/)
简单命令 docker安装
```bash
gitea gitea@123
root gitea@123
flyaway Xxw!123
docker pull gitea/gitea:1.14.2
docker pull gitea/gitea:1.14.3
# DB_HOST 等参数好像实际没什么用,还是得安装页面配置 SSH_PORT 也没用
# 还是在运行起来后修改配置文件
docker run --name gitea -p 3010:3010 -v /mnt/user/appdata/gitea:/data \
-e "RUN_MODE=prod" \
-e "DOMAIN=192.168.66.254" \
-e "HTTP_PORT=3010" \
-e "ROOT_URL=http://192.168.66.254:3010" \
-e "DB_TYPE=mysql" \
-e "DB_HOST=192.168.66.254" \
-e "DB_NAME=gitea" \
-e "DB_USER=gitea" \
-e "DB_PASSWD=gitea@123" \
-e "USER_UID=1000" \
-e "USER_GID=100" \
--env=TZ=Asia/Shanghai \
-d gitea/gitea:1.14.2
```
### 组织和团队有啥区别 #1912
[组织和团队有啥区别 · Issue #1912 · gogs/gogs](https://github.com/gogs/gogs/issues/1912)
> organization => company
> team => department or small unit
[Organization / teams structure - Support - Gitea](https://discourse.gitea.io/t/organization-teams-structure/2766)
### Gitea is running slow
The most common culprit for this is loading federated avatars.
This can be turned off by setting `ENABLE_FEDERATED_AVATAR `to `false` in your app.ini
Another option that may need to be changed is setting `DISABLE_GRAVATAR `to true in your `app.ini`
```ini
[picture]
DISABLE_GRAVATAR = true
ENABLE_FEDERATED_AVATAR = false
```
### Gitea avatar 修改 cdn
```ini
GRAVATAR_SOURCE=https://gravatar.cat.net/avatar/ # 感觉不靠谱
```
```shell
# 升级后 好像这个文件会丢失
/data01/devops/gitea/data/avatars
上传 asia_ico_20210610201425-25.jpg
改名
asia_ico_20210610201425
mv asia_ico_20210610201425-25.jpg asia_ico_20210610201425
```
### gitea webhook i/o timeout
webhook 超时报错问题
[Re: Webhook i/o timeout failure - Shopify Community](https://community.shopify.com/c/Shopify-APIs-SDKs/Webhook-i-o-timeout-failure/m-p/825409)
<br />
[Webhooks randomly fail with 408 timeout · Issue #5470 · go-gitea/gitea](https://github.com/go-gitea/gitea/issues/5470)
[Internal server Error · Issue #10246 · go-gitea/gitea](https://github.com/go-gitea/gitea/issues/10246)
很可能是`.drone.yml `文件名错了
> ok. I have solved this problem.
> my gitea repository's webhook is Drone URL. and the point is that CI `repository - setting - Main - Configuration` specified yaml file named `.drone.yml`, and my git repository's file named `drone.yml`!!
> that's worker after modified file name... :)
>
或者是版本库有问题
> Update: I deleted the repository and pushed again and that worked fine.
>
### Gitea webhook push 消息不对的问题,是因为配置文件中`html_url` 是 `localhost` ,导致 push的消息不对
导致 `jenkins` 无法正常自动触发
日志 `/data01/docker_appdata/jenkins/logs/jenkins.branch.MultiBranchProject.log` 中就会出现 `Matched 0 错误` 的问题,正常应该是 `Matched 1` 或其他。
```ini
SSH_DOMAIN = cqaivm.860001.xyz
DOMAIN = cqaivm.860001.xyz
ROOT_URL = http://cqaivm.860001.xyz:12239/
```
### gitea 关闭用户注册
注意是 service 不是 server
https://docs.gitea.io/en-us/config-cheat-sheet/
`custom/conf/app.ini `
```ini
[service]
DISABLE_REGISTRATION = true
```
### gitea 登录才能浏览
```ini
[service]
REQUIRE_SIGNIN_VIEW = true
```
### Gitea  Jenkins 上返回的仓库数目不对的问题
gitea  api 限制
```ini
[api]
MAX_RESPONSE_ITEMS = 200
DEFAULT_PAGING_NUM = 100
# 注意好像可能有配置的顺序问题,或者大小限制
```
- 官方代码仓库里面 `custom/conf/app.example.ini` 有示例
- [[JENKINS-63048] gitea API added general pagination in 1.12.x (potentially affecting repo listings) - Jenkins Jira](https://issues.jenkins.io/browse/JENKINS-63048)
- [[JENKINS-64059] Scan Gitea Organization limited to 30 repositories - Jenkins Jira](https://issues.jenkins.io/browse/JENKINS-64059)
google `jenkins gitea Repository limit`
### Gitea API
[https://try.gitea.io/api/swagger](https://try.gitea.io/api/swagger)
### 其他工具 Awesome Gitea
[gitea/awesome-gitea: A curated list of awesome projects related to Gitea - README.md at master - awesome-gitea - Gitea: Git with a cup of tea](https://gitea.com/gitea/awesome-gitea/src/branch/master/README.md#user-content-devops)
[Awesome Gitea](https://gitea.com/gitea/awesome-gitea/src/branch/master/README.md)
# 更新 升级 gitea [[2022-02-16]]
注意升级后可能头像文件asiainfo丢失
gitea-1.15.6-linux-amd64.xz
改成
gitea-1.16.1-linux-amd64.xz
[[2022-03-10]]
gitea-1.16.3-linux-amd64.xz
[[2022-05-03]]
gitea-1.16.7-linux-amd64.xz
```shell
cd /data01/devops/gitea
vi custom/conf/app.ini
[service]
REQUIRE_SIGNIN_VIEW = true
# 注意停止旧的进程
# ps -ef|grep gitea
pid1=`ps -ef|grep gitea|grep -v grep|grep -v bash|awk '{print $2}'`
kill -9 ${pid1}
mv gitea bak_gitea_1.15.6
xz -d gitea-1.16.3-linux-amd64.xz
mv gitea-1.16.3-linux-amd64 gitea
chmod u+x gitea
nohup ./gitea web > log.file 2>&1&
```
## 1.16 Webhook
```shell
webhook can only call allowed HTTP servers (check your webhook.ALLOWED_HOST_LIST setting), deny 'cqaivm.860001.xyz(127.0.0.1:12250)'
```
新版要设置 webhook
`ALLOWED_HOST_LIST`: **external**: Since 1.15.7. Default to `*` for 1.15.x, `external` for 1.16 and later. Webhook can only call allowed hosts for security reasons. Comma separated list.
- Built-in networks:
- `loopback`: 127.0.0.0/8 for IPv4 and ::1/128 for IPv6, localhost is included.
- `private`: RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and RFC 4193 (FC00::/7). Also called LAN/Intranet.
- `external`: A valid non-private unicast IP, you can access all hosts on public internet.
- `*`: All hosts are allowed.
- CIDR list: `1.2.3.0/8` for IPv4 and `2001:db8::/32` for IPv6
- Wildcard hosts: `*.mydomain.com`, `192.168.100.*`
```ini
[webhook]
ALLOWED_HOST_LIST = *
```