colynn / colynn.github.io

Colynn's Blog
https://colynn.github.io
2 stars 0 forks source link

drone in using #15

Open colynn opened 4 years ago

colynn commented 4 years ago

前置条件

  1. 正确创建 admin 帐号
    • admin 帐号基于你可以登录git仓库的用户来进行配置, 如你想授权为 admin 的帐号为 yuan.liu, 则添加如下参数至启动命令。 DRONE_USER_CREATE=username:yuan.liu,admin:true
  2. 下载 drone cli工具
    • 你可以检查 User Settings获取执行 CLI的例子。

Issue1

Error Log

Linter: untrusted repositories cannot mount host volumes

Solution

You have to set it up thourgh CLI:

drone repo update --trusted <your/repo>

Issus2 - (Gitlab 项目不能Activate)api: cannot create or update hook

Error Log

{"error":"","level":"debug","msg":"api: cannot create or update hook","name":"helloworld","namespace":"colynn","request-id":"1hcwYI3tnVgKrmxK5VqQAETP024","time":"2020-09-17T06:22:13Z","user.admin":true,"user.login":"colynn"}

Note: 此为设置DRONE_LOGS_TRACE=true的日志显示。

Error Snapshot

image

Solution

First, double-check you have admin permissions to the repository in Gitlab. The admin=true in the logs could indicate you are a Drone admin and does not necessarily guarantee you have sufficient privileges to add webhooks in Gitlab

Second, you might look at your Gitlab server logs to see exactly why the webhook creation fails. This will usually provide a more detailed error message that will help immediately identify the issue.

Third, check to make sure you do not have a reverse proxy that is somehow mutating the request or redirecting the request. If this happens, the POST request gets turned into a GET request which can result in failure.

Finally, I recommend you use the command of tcpdump to fetching HTTP packets], then use postman try to run it manually. You may be getting a more detailed response log.

Others, you can taking a look at some of the existing threads on the drone forum which may help provide some insight. For example, check out Error Activating Gitlab Repository and search the forum for other threads that contain the same error message.

我的解决方案是到了最后一步,通过 postman 请求发现如下响应日志

{
    "error": "Invalid url given"
}

由于我配置的 drone 地址是内网地址,所以Gitlab 需求 enable Allow requests to the local network from webhooks and services, 然后重试即可解决。->You can get here get more detail info Webhooks and insecure internal web services