Bitbucket integration

Hello,

I am new to drone.io and I would like to set it up to work with Bitbucket.

I am triyng to use docker-compose for it and I am unable to make it work. This is my docker-compose for drone:

version: '3'

services:
  drone-server:
    image: drone/drone
    restart: always
    ports:
      - 80:8000
      - 9000
    
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=https://192.168.1.7
      - DRONE_BITBUCKET=true
      - DRONE_BITBUCKET_CLIENT=xyz
      - DRONE_BITBUCKET_SECRET=xyz
      - DRONE_SECRET=OpD8X603IozTqnffP2Cp1Luz
  #--------------------------------------------------------------------------------
  drone-agent:
    image: drone/agent

    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server:9000
      - DRONE_SECRET=OpD8X603IozTqnffP2Cp1Luz

What I always get for an error is:

Invalid redirect_uri This integration is misconfigured. Contact the vendor for assistance.

I want to use drone on my server that resides in my room. It’s IP is always 192.168.1.7
Do I need to do something specific in OAuth settings on Bitbucket? Do I have to do something with IP?

Thank you.

The most common root cause for Invalid redirect_uri is when the redirect url is not configured properly when creating your Bitbucket oauth client. When Drone redirects to Bitbucket for login, it send a redirect_url query parameter, which must match exactly what you configured in Bitbucket.

Do I need to do something specific in OAuth settings on Bitbucket? Do I have to do something with IP?

The redirect happens client-side in the browser. So there are no issues using a localhost address in your authorization flow. With that being said, Bitbucket cannot send webhooks to 192.168.1.7, which means you will be unable to activate a repository in Drone. You must have a public address in order to receive webhooks from a public version control system.

So, would I be able to do it with dyn dns address?

So, would I be able to do it with dyn dns address?

I don’t know what that is … but you basically need an IP address or hostname that can be reached by Bitbucket. If Bitbucket cannot post an HTTP request to your Drone server, it will not be able to trigger builds.

1 Like

Thanks, that is really good answer you gave me. And I think stuff like that should be provided in documentation. I bet there would be a more people with same question like mine.

If you are setting up drone on your local machine, it might be worth it to use a tool such as ngrok.
According to your docker-compose.yml you would just need to run ngrok http 80 and it will create a tunnel with a public url for you that will forward traffic to your local machine port 80. Use that url for DRONE_HOST and also for the OAUTH authorization url in bitbucket.

Of course everything is much easier if you have your own domain already :wink:

@moderators: Discourse rule of "new users can only put 2 links in the post makes it very hard to provide a helpful answer…