Drone

Migration error: Cannot activate repos (bitbucket cloud)

Hi,
I’m migrating from 0.8 to 1.2 for fixing issue with bitbucket v2 API.
During migration process I had to deactivate all repos due to it failed on update-repos command (credentials error).
Now drone server 1.2 is working but when I try to activate a repo it fails and gives again a credential error:

There was a problem enabling your repository.
Your credentials lack one or more required privilege scopes…

Considerations:

  • my user is administrator of the repository and application drone have grant access in my account
  • there isn’t reverse proxy server
  • custom port 8050 for drone server

Here is my compose file:

  drone-server:
    image: drone/drone:1.2
    ports:
      - 8050:80
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_SERVER_HOST=${DRONE_HOST}:${DRONE_PORT}
      - DRONE_SERVER_PROTO=${DRONE_PROTO}
      - DRONE_TLS_AUTOCERT=false
      - DRONE_BITBUCKET_CLIENT_ID=${DRONE_BITBUCKET_CLIENT}
      - DRONE_BITBUCKET_CLIENT_SECRET=${DRONE_BITBUCKET_SECRET}
      - DRONE_REPOSITORY_FILTER=datalife_sco
      - DRONE_RUNNER_CAPACITY=${DRONE_MAX_PROCS}
      - DRONE_LOGS_DEBUG=true

and the debug log:

{"level":"debug","msg":"events: stream opened","request-id":"1NVetfxebuRfZcB7WbgzRDDG8YT","time":"2019-07-03T16:21:47Z","user.login":"sergyo"}
{"fields.time":"2019-07-03T16:21:47Z","latency":11730246,"level":"debug","method":"GET","msg":"","remote":"172.29.1.176:47052","request":"/api/user/repos?latest=true","request-id":"1NVethBv3PLTSmKBSSUqu1h0wZ7","time":"2019-07-03T16:21:47Z"}
{"level":"debug","msg":"api: read access granted","name":"trytond-account_asset_percentage","namespace":"datalife_sco","request-id":"1NVetsB3G8TBbIvWd6rypoSFIYQ","time":"2019-07-03T16:21:48Z","user.login":"sergyo","visibility":"public"}
{"admin":true,"level":"debug","msg":"api: access granted","name":"trytond-account_asset_percentage","namespace":"datalife_sco","read":true,"request-id":"1NVetsB3G8TBbIvWd6rypoSFIYQ","time":"2019-07-03T16:21:48Z","user.login":"sergyo","visibility":"public","write":true}
{"error":"Your credentials lack one or more required privilege scopes.","level":"debug","msg":"api: cannot create or update hook","name":"trytond-account_asset_percentage","namespace":"datalife_sco","request-id":"1NVetsB3G8TBbIvWd6rypoSFIYQ","time":"2019-07-03T16:21:48Z","user.login":"sergyo"}
{"fields.time":"2019-07-03T16:21:48Z","latency":470109679,"level":"debug","method":"POST","msg":"","remote":"172.29.1.176:46836","request":"/api/repos/datalife_sco/trytond-account_asset_percentage","request-id":"1NVetsB3G8TBbIvWd6rypoSFIYQ","time":"2019-07-03T16:21:48Z"}

Any idea?

This error comes from bitbucket. There are only 2 root causes that I am aware of for this error. Either you lack admin access to the repository (you have indicated this is not the case) or the oauth2 application was not created with the correct scopes.

There error message seems to indicate this is an issue with scope, so I recommend double-checking your configuration and if you continue to experience issues you might want to check with bitbucket support.

Your credentials lack one or more required privilege scopes

Thanks! you point me out to the real issue.
I missed to add permissions to Pull request as described on official documentation.

Now I can activate repositories!

Sorry,
I decided to execute the migration process again to solve update-repos issue. All the process finish correctly, but when a start drone server the activity feed of all repositories are empty; no build history are present. Repository secrets are empty as well.
Am I missing anything?

Solved!
I miss to define DRONE_DATABASE_DATASOURCE environment variable so container was connecting to a fresh database.
Sorry for the inconvenience …