# Drone is not cloning from Bitbucket Server

**URL:** <https://drone.discourse.group/t/drone-is-not-cloning-from-bitbucket-server/9977>\
**Category:** Drone Support\
**Created:** [August 13, 2019, 5:15am UTC](https://drone.discourse.group/t/drone-is-not-cloning-from-bitbucket-server/9977 "2019-08-13T05:15:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbair23](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rbair23](https://drone.discourse.group/u/rbair23)\
**Post date:** [August 13, 2019, 5:15am UTC](https://drone.discourse.group/t/drone-is-not-cloning-from-bitbucket-server/9977/1 "2019-08-13T05:15:40Z")

</div>

I have Bitbucket server setup, and I have Drone setup. Drone sees my repo and attempts to build. When it does, I get an error saying that it was unable to clone the repo.

To diagnose, I tried to run the drone/git plugin manually. I found that the following works:

docker run -e DRONE\_COMMIT=$my\_commit -e DRONE\_COMMIT\_BRANCH=master -e DRONE\_REMOTE\_URL=https://$my\_host/scm/infra/microservice-tas-sm.git -e DRONE\_NETRC\_MACHINE=$my\_host -e DRONE\_NETRC\_USERNAME=drone -e DRONE\_NETRC\_PASSWORD=$my\_token drone/git drone/git

I then captured the env variables passed at runtime to a transient container (I assume it is the drone/git container) that was created when I hit “Restart” in the browser. This container had an empty DRONE\_REMOTE\_URL and an empty DRONE\_NETRC\_MACHINE, but it had the DRONE\_NETRC\_USERNAME and DRONE\_NETRC\_PASSWORD specific correctly.

My believe is that the clone is failing due to the missing env variables. Is this known to work? I didn’t manage to see in the code where these env variables are being set or where the drone/git is being configured and called.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 13, 2019, 5:26am UTC](https://drone.discourse.group/t/drone-is-not-cloning-from-bitbucket-server/9977/2 "2019-08-13T05:26:24Z")

</div>

> Is this known to work?

Yes, we test Drone against all supported source control management systems. We have our own Bitbucket Server installation that we used to develop the integration, and there are production installations using this integration.

> My belief is that the clone is failing due to the missing env variables.

the DRONE\_REMOTE\_URL and DRONE\_NETRC\_MACHINE values come from the Bitbucket repository endpoint. If the value is empty it would imply Bitbucket returns an empty value in the response payload. Here is an example payload from our test instance: [https://github.com/drone/go-scm/blob/master/scm/driver/bitbucket/testdata/repos.json#L24](https://github.com/drone/go-scm/blob/master/scm/driver/bitbucket/testdata/repos.json#L24)

> I didn’t manage to see in the code where these env variables are being set

They are being set [here](https://github.com/drone/drone/blob/2730e336d2537a4ea9a974e6d15c9a43608644c6/operator/runner/env.go#L54)

> I didn’t manage to see in the code where these env variables are being set or where the drone/git is being configured and called.

It is being configured [here](https://github.com/drone/drone-yaml/blob/a4a63fe917cb19cafd277dcc3d71eb1b5fdf2723/yaml/compiler/clone.go#L47).

---

<div class="post-metadata">

**Author:** ![rbair23](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rbair23](https://drone.discourse.group/u/rbair23)\
**Post date:** [August 13, 2019, 1:23pm UTC](https://drone.discourse.group/t/drone-is-not-cloning-from-bitbucket-server/9977/3 "2019-08-13T13:23:33Z")

</div>

Thank you, that was the key I needed. I had started Drone and sync’d the repo **before** I had enabled HTTPS cloning in bitbucket. I restarted Drone, but that didn’t pick up the fresh configuration. Instead, I had to hit “sync” again in Drone, and then it picked up the new config and worked as expected.

Now that I understand how the integration works, it is clear to me. I was missing some high level description in the [Drone.io](http://Drone.io) docs of how the system worked. Perhaps that would be a worthy enhancement.

Thanks!

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 13, 2019, 4:08pm UTC](https://drone.discourse.group/t/drone-is-not-cloning-from-bitbucket-server/9977/4 "2019-08-13T16:08:27Z")

</div>

> [@On another topic](https://drone.discourse.group/t/5336/3):
>
> I was missing some high level description in the [Drone.io](http://Drone.io) docs of how the system worked. Perhaps that would be a worthy enhancement.

we are aware that the documentation needs significant improvement, however, we are also very resource constrained. I appreciate the feedback and we will do our best to take this into account as we continue to improve the docs.
