Error Activating Gitlab Repository


#1

Hi Drone team,

I’m having issues activating any repository in my gitlab account. When trying to activate any of my repos in GitLab, I get the error:

There was a problem enabling your repository.

I am trying to follow some suggestions already made in previous threads but to no avail.

  1. you do not have admin permissions to the repository which is required in order to create webhooks
  • I’m logged in to Drone via Gitlab OAuth. My user account is an admin account
  1. the drone application oauth client was not configured with the correct scopes in gitlab
  • All the scopes have been selected. None have been left unticked.
  1. the url is invalid or cannot be reached by gitlab (e.g. your drone address is localhost).
  • My drone address is a private IPV4 address in the same subnet as my gitlab account. From the gitlab server I can do a curl and a ping to the Drone server and vice versa

Here is my docker command. I am not using a docker-compose file yet as I’m following the instructions in the Drone.io site:
docker run
–volume=/var/run/docker.sock:/var/run/docker.sock
–volume=/var/lib/drone:/data
–env=DRONE_ADMIN=zac,zacsarion
–env=DRONE_GIT_ALWAYS_AUTH=false
–env=DRONE_GITLAB_SERVER=https://git.ops.mobilise.cloud
–env=DRONE_GITLAB_CLIENT_ID=c68fceff62352e282d0bb1217c331c3a29fd2766cc9f28089d0952c1102e747d \ --env=DRONE_GITLAB_CLIENT_SECRET=335ae6bf096abe8277943630d2eee21ef0bc117bcaee04f62921ec7bad17dbe6
–env=DRONE_RUNNER_CAPACITY=2
–env=DRONE_SERVER_HOST=10.200.20.160
–env=DRONE_SERVER_PROTO=http
–env=DRONE_TLS_AUTOCERT=false
–publish=80:80
–publish=443:443
–restart=always
–detach=true
–name=drone
drone/drone:1.0.0-rc.1

Any other ideas? Thanks in advance!


#2

A few things

This environment variable is no longer valid. See DRONE_USER_CREATE if you want to create an initial administrative account in Drone.

docker run 
  –volume=/var/run/docker.sock:/var/run/docker.sock 
  –volume=/var/lib/drone:/data 
- –env=DRONE_ADMIN=zac,zacsarion 

Also just to clarify, you need to have admin access to the repository in GitLab. Being a Drone admin will not make a difference. When you try to activate the repository, Drone uses your GitLab oauth token to create a webhook, and that oauth token needs to have admin access to the repository to perform this action.


#3

Hi @bradrydzewski! Thanks for your reply! Actually my account (using the same account name in Drone) is also admin on our private Gitlab server. I removed the - –env=DRONE_ADMIN entry from my docker run command and re-created my docker image but I’m still getting the same issue.
I’m also trying to find any logs in Gitlab or the drone instance but I am not getting any pertinent information. Not sure if I’m looking at the correct messages though…
I’m just running docker logs on the container…

{“level”:“info”,“msg”:“main: starting the local build runner”,“threads”:2,“time”:“2018-12-06T19:20:48Z”}
{“acme”:false,“host”:“10.200.20.160”,“level”:“info”,“msg”:“main: starting the http server”,“port”:":80",“proto”:“http”,“time”:“2018-12-06T19:20:48Z”,“url”:“http://10.200.20.160”}
{“interval”:1800000000000,“level”:“info”,“msg”:“main: cron schedule disabled”,“time”:“2018-12-06T19:20:48Z”}


#4

You can enable debug logging with the DRONE_LOGS_* environment variables. That might provide you with more details. I can confirm that I am able to activate private GitLab repositories (using gitlab.com)


#5

Hi @bradrydzewski!

Thanks! I tried setting up drone and have it point to a private repo on https://gitlab.com and that works fine as well! Have you had any success setting drone up to sync with a private gitlab server? I have my drone setup using a private gitlab server in AWS behind a load balancer. The oauth works oK with the server and I can see all my repos, but I’m still getting an error when trying to enable any of my repos…

Here’s a log of the possible issue:
The first part shows login successful
{
“fields.time”: “2018-12-10T10:51:51Z”,
“latency”: 16438,
“level”: “debug”,
“method”: “GET”,
“msg”: “”,
“remote”: “10.200.1.237:27246”,
“request”: “/”,
“request-id”: “1E9ySo0VzqFwG9Wgk9Q7MZSqFF2”,
“time”: “2018-12-10T10:51:51Z”
}
{
“level”: “debug”,
“login”: “zacsarion”,
“msg”: “attempting authentication”,
“time”: “2018-12-10T10:51:53Z”
}
{
“level”: “debug”,
“login”: “zacsarion”,
“msg”: “authentication successful”,
“time”: “2018-12-10T10:51:53Z”
}

But when I go to activate my repo drone-test:
{
“fields.time”: “2018-12-10T10:52:04Z”,
“latency”: 799431,
“level”: “debug”,
“method”: “GET”,
“msg”: “”,
“remote”: “10.200.0.47:23106”,
“request”: “/api/repos/zacsarion/drone-test/secrets”,
“request-id”: “1E9yUOUuixTP7uUheMLSWhSjbik”,
“time”: “2018-12-10T10:52:04Z”
}
{
“admin”: true,
“level”: “debug”,
“msg”: “api: access granted”,
“name”: “drone-test”,
“namespace”: “zacsarion”,
“read”: true,
“request-id”: “1E9yUPnHLvwdC4WtBtCCFk25khe”,
“time”: “2018-12-10T10:52:04Z”,
“user.login”: “zacsarion”,
“visibility”: “private”,
“write”: true
}
{
“admin”: true,
“level”: “debug”,
“msg”: “api: access granted”,
“name”: “drone-test”,
“namespace”: “zacsarion”,
“read”: true,
“request-id”: “1E9yUPnHLvwdC4WtBtCCFk25khe”,
“time”: “2018-12-10T10:52:04Z”,
“user.login”: “zacsarion”,
“visibility”: “private”,
“write”: true
}
{
“fields.time”: “2018-12-10T10:52:04Z”,
“latency”: 663184,
“level”: “debug”,
“method”: “GET”,
“msg”: “”,
“remote”: “10.200.0.47:23106”,
“request”: “/api/repos/zacsarion/drone-test/cron”,
“request-id”: “1E9yUPnHLvwdC4WtBtCCFk25khe”,
“time”: “2018-12-10T10:52:04Z”
}
{
“admin”: true,
“level”: “debug”,
“msg”: “api: access granted”,
“name”: “drone-test”,
“namespace”: “zacsarion”,
“read”: true,
“request-id”: “1E9yVEh3OAJdZWGUHwKgT9LaRhr”,
“time”: “2018-12-10T10:52:10Z”,
“user.login”: “zacsarion”,
“visibility”: “private”,
“write”: true
}
{
“admin”: true,
“level”: “debug”,
“msg”: “api: access granted”,
“name”: “drone-test”,
“namespace”: “zacsarion”,
“read”: true,
“request-id”: “1E9yVEh3OAJdZWGUHwKgT9LaRhr”,
“time”: “2018-12-10T10:52:10Z”,
“user.login”: “zacsarion”,
“visibility”: “private”,
“write”: true
}
{
“error”: “”,
“level”: “debug”,
“msg”: “api: cannot create or update hook”,
“name”: “drone-test”,
“namespace”: “zacsarion”,
“request-id”: “1E9yVEh3OAJdZWGUHwKgT9LaRhr”,
“time”: “2018-12-10T10:52:10Z”,
“user.login”: “zacsarion”
}
{
“fields.time”: “2018-12-10T10:52:10Z”,
“latency”: 53430755,
“level”: “debug”,
“method”: “POST”,
“msg”: “”,
“remote”: “10.200.0.47:23106”,
“request”: “/api/repos/zacsarion/drone-test”,
“request-id”: “1E9yVEh3OAJdZWGUHwKgT9LaRhr”,
“time”: “2018-12-10T10:52:10Z”
}


#6

I have not personally, but we do have a number of teams using Drone with private Gitlab installations and they have not reported any issues.

These are the possible reasons creating a webhook would fail. I know you already ruled out the first, but wanted to provide all options in case anyone else comes across this thread :slight_smile:

  1. you do not have admin access to the repository in GitLab
  2. you may not be able to create a webhook if your Drone address is localhost (127.0.0.1, etc) or unreachable from your gitlab instance
  3. you gave Drone an http address to GitLab and the loadbalancer or server is auto-redirecting from http to https. GET requests will redirect without issue, but POST requests will redirect as a GET request with no body, which would cause an error.