Comments (7)
I would be ok with it if we can abstract the provider to an interface. That way it should be easy to add new providers afterwards.
For now we would have just a bitbucket and a github provider. Users that require more would be able to add them.
Thanks for taking the time!
from drone-tree-config.
If i remind correctly: if one pushes multiple commits newref~1
and oldref
are diffrent.
from drone-tree-config.
this would require some code changes and some new test.
https://github.com/drone/go-scm can handle all provides that drone uses.
i you or someone else wants do do the changes, i am happy to merge them.
from drone-tree-config.
I forked this repository to attempt the changes myself. I have no previous experience with golang, but it seems like we are going to hit a wall with go-scm
because two API calls are missing. That means we have two options.
- Make a PR for https://github.com/drone/go-scm with implementations for the missing calls for every SCM system.
- Implement the necessary logic as part of this plugin, focus on BitBucket for the moment and add repositories as we go along.
Missing API calls
changes, _, err := req.Client.Repositories.CompareCommits(ctx, req.Repo.Namespace, req.Repo.Name, before, req.Build.After)
The first is a call to repos/%s/compare/oldref...newref
to run a diff between two commits. I wonder if we can just call repos/%s/commits/newref
instead?
_, ls, _, err := req.Client.Repositories.GetContents(ctx, req.Repo.Namespace, req.Repo.Name, dir, &ref)
The second is more troublesome, in that the call to repos/%s/contents/path
accepts directories, but the source code of go-scm
assumes that you're calling it on a file, causing it to crash because the response has a different format than the one expected. See https://developer.github.com/v3/repos/contents/#get-contents.
I worry that adding the above two API calls to go-scm
is going to take a long time. Is there anyone that could help with that? Alternatively, would you accept a PR for drone-tree-config
that just implements BitBucket support natively in this plugin?
from drone-tree-config.
Thanks, I'll do my best to find the time for that! Regarding the first API call, is there a difference between /compare/oldref...newref
and /commits/newref
? It seems to me that the content of a commit is by definition the same as the diff with the previous commit, but I might be overlooking something.
(This is assuming that oldref
is newref~1
, which seems to always be true in the source code.)
Edit: also made an issue in go-scm for long term improvement.
from drone-tree-config.
I managed to extract a common interface and finish an implementation with BitBucket support. I'll test it over the next few days and send a PR.
Edit: #4
It's quite a big change due to SCM-specific code having to be separated. It is fully backwards compatible with one exception, I thought it better to rename the GITHUB_SERVER
variable to SERVER
rather than making separate versions for each SCM. I have the image up on jodiug/drone-tree-config
, if anyone in the community would like to test it that would be very helpful.
The following environment variables need to be passed to drone-tree-config to add BitBucket support:
AUTH_SERVER: https://bitbucket.org
SERVER: https://api.bitbucket.org
BITBUCKET_CLIENT: client_id
BITBUCKET_SECRET: client_secret
You can use the same client credentials as you use for drone-master.
from drone-tree-config.
Hey @Oduig,
awesome! I will have a detailed look and test against our infrastructure in the next few days.
Thanks for taking time!
from drone-tree-config.
Related Issues (20)
- Failed SCM connections should be handled properly HOT 4
- Auth server for BitBucket client is not specified HOT 6
- Gitlab support? HOT 4
- v0.3.4 fails to trigger builds on master branch in monorepo HOT 8
- Add support for root folder files changing - trigger multiple pipelines HOT 2
- Git tags / Release support HOT 3
- How to use it on k8s HOT 2
- The plugin omit "..." in commands in steps HOT 2
- Documentation: Timeouts of consideration HOT 1
- Drone rebuilds everything every time HOT 7
- Jsonnet support HOT 6
- Rate limit hit HOT 1
- did not find a .drone.yml HOT 4
- Docker images for ARM
- bitbucket cloud authorization error
- BitBucker Server(previously known as Stash) support?
- Add GitLab self-hosted support? HOT 1
- Wait the end of all pipelines? HOT 7
- Gitea support? HOT 7
- Multiple commits HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drone-tree-config.