How to use bitbucket repositories on mybinder.org

how-to
#1

You can use arbitrary Git repositories with a BinderHub. Not just GitHub.com and GitLab.com. Related to this a question came up on how to actually do it.

Duplicating my answer here to make it easier to find.

The repo in question is: https://bitbucket.org/ueacomputervision/image-labelling-tool/src/master/

The launch link for it is: https://mybinder.org/v2/git/https%3A%2F%2Fbitbucket.org%2Fueacomputervision%2Fimage-labelling-tool.git/f3ddb33e4839f8a0fe73c168993b405adc13daf0

and when you fill in the form it looks like this:

You need to explicitly specify the revision you want, you can’t write master for the “arbitrary git URL” mode as we have no way to resolve that “word” into a revision, which is what we need to check the build cache. For GitHub and GitLab there is a little bit of magic to talk to the respective APIs to resolve it first. Could add this for bitbucket as well if someone is interested enough to open a PR.

1 Like
#2

One place you can get the ID for a particular commit is from a Bitbucket repo’s Commits page eg https://bitbucket.org/ueacomputervision/image-labelling-tool/commits/all . The ID comes at the end of the URL for a commit. For example, the commit identified as f3ddb33 gives the link:

https://bitbucket.org/ueacomputervision/image-labelling-tool/commits/f3ddb33e4839f8a0fe73c168993b405adc13daf0

which gives the commit hash f3ddb33e4839f8a0fe73c168993b405adc13daf0 used in the demo above.

1 Like
#3

git ls-remote can fetch sha1s without a local clone, e.g.:

$ git ls-remote https://bitbucket.org/ueacomputervision/image-labelling-tool
f3ddb33e4839f8a0fe73c168993b405adc13daf0        HEAD
8116559e4030d1d4f557617780410cbca7896663        refs/heads/canvas
d50105bacbb74ca139c5bf38ef1657190a006929        refs/heads/group
f3ddb33e4839f8a0fe73c168993b405adc13daf0        refs/heads/master
0b92e511ce8e04f26131efddde9b4a2f5ef9e1e1        refs/heads/multi-user
bc53e6aa12b6d7988de514c8c92e29877be5cc61        refs/heads/separate-modules
a1b2c3bcc2e563afbd335013805d19c95d67224d        refs/heads/server-side-refactor
$ git ls-remote https://bitbucket.org/ueacomputervision/image-labelling-tool master
f3ddb33e4839f8a0fe73c168993b405adc13daf0        refs/heads/master

This might provide a generic alternative to using provider specific APIs?

1 Like
#4

Nice! Could you open an issue on https://github.com/jupyterhub/binderhub with the git ls-remote idea?

We could already add this to the “bare git repo” provider https://github.com/jupyterhub/binderhub/blob/0b8f99af0a23a7828810b03f010edcefc9a46195/binderhub/repoproviders.py#L126-L160

#5

See

1 Like