Actually, I just checked the API and currently there's no way to create a
repository bound to a hosting service. We do have plans in the roadmap to
add that, but it's not in any shipping release today.
The reason what you have isn't sufficient is that your API call is
attempting to create an entry for a plain Git repository, not one hosted
anywhere. Git's protocol is overly simplistic and doesn't provide the
capabilities needed for any real remote communication, aside from doing
full clones. No fine-grained access. Because of that, repositories must be
associated with a hosting service so its API can be used instead. And with
our API, there's no way today to do that.
What you can try doing is to have a script you can run on the Review Board
server that would use the Review Board Python API directly to create the
repository. Instead of remotely requesting the construction of this
repository via a REST API call, you'd run the script with the appropriate
parameters. Here's a rough (untested) template for a script:
----------
#!/usr/bin/env python
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'reviewboard.settings'
sys.path.insert(0, '/path/to/sitedir/conf')
from reviewboard.hostingsvcs.models import HostingServiceAccount
from reviewboard.scmtools.forms import RepositoryForm
from reviewboard.scmtools.models import Tool
# Make sure to look up the ID found in the URL for the pre-configured
GitLab Hosting Service Account entry in the admin UI.
hosting_account = HostingServiceAccount.objects.get(pk=<YOUR GITLAB ACCOUNT
ENTRY ID>)
form = RepositoryForm(data={
'name': '<YOUR REPOSITORY NAME>',
'hosting_type': 'gitlab',
'hosting_account': hosting_account,
'tool': Tool.objects.get(name='Git'),
'repository_plan': 'group',
'bug_tracker_use_hosting': True,
'hosting_url': '<YOUR GITLAB URL>',
'gitlab_group_name': '<YOUR GITLAB GROUP NAME FOUND IN URL>',
'gitlab_group_repo_name': '<YOUR GITLAB REPO NAME FOUND IN URL>',
})
form.save()
----------
There may be other fields required here, and this is assuming group-owned
and not user-owned repositories. (For that, your "repository_plan" must be
"personal" and your "gitlab_*" should be replaced with
"gitlab_personal_repo_name". This code is completely untested, but would
hopefully serve as a start.
You'll likely also need to upgrade Review Board to a newer 2.5.x release,
as there have been a number of GitLab-related repository configuration
fixes since 2.5.4.
Christian
--
Christian Hammond
President/CEO of Beanbag <https://www.beanbaginc.com/>
Makers of Review Board <https://www.reviewboard.org/>
On Tue, Mar 7, 2017 at 5:33 AM, spacekangaroo <[email protected]> wrote:
> Hello Christian,
>
> mmh using using the parameter for “username“ and „password“ in create()
> makes sense ... but I get the same exception.
>
> 1. I’m using v2.5.4 of reviewboard.
> 2. Of course the repository exists :). I can add it in reviewboard by
> using the GUI. Now I delete it and try to add it by using the script.
> 3. Finally this script should add every repository from GitLab to
> reviewboard … best in real time when it’s generated in Git
>
> What are the specific GitLab fields? I assume that the parameters “tool”
> and "path" are responsible for it.
>
> regards
> Daniel
>
> Am Montag, 6. März 2017 20:50:01 UTC+1 schrieb Christian Hammond:
>>
>> Hi Daniel,
>>
>> The username and password being supplied to Client() is for your own
>> Review Board user. I don't see any credentials being passed for the
>> repository in the create call, and that's where it's complaining. HTTP vs
>> HTTPS isn't a factor.
>>
>> I also don't see anything in that call specifying that it's a GitLab
>> service or specifying GitLab-specific fields. You won't be able to create a
>> repository entry that's plain Git and point it to a GitLab. The two work
>> very differently.
>>
>> A few additional questions to best help you:
>>
>> 1) What version of Review Board are you using?
>>
>> 2) Does this repository on GitLab already exist?
>>
>> 3) What's the ultimate purpose of the script?
>>
>> Christian
>>
>>
>> On Mon, Mar 6, 2017 at 09:14 spacekangaroo <[email protected]> wrote:
>>
>>> Hello everybody,
>>>
>>> I’ve tried to create a GitLab in ReviewBoard. It looks simple first
>>>
>>> from rbtools.api.client import RBClient
>>> client = Client('http://localhost:8080/',username='username',password=
>>> 'password')
>>> root = client.get_root()
>>> repos = root.get_repositories()
>>> repos.create(name='myRepository', tool='Git', path=
>>> 'server:myGroup/myTestRepository.git', trust_host=1)
>>>
>>> I get an exception:
>>>
>>> APIError: Unable to authenticate with the repository using the provided
>>> credentials. (HTTP 403, API Error 218)
>>>
>>> … the GitLab exists, user and password are correct too. I see reasons
>>> for HTTP 403 exception are no authorization or a *https* URL is calling
>>> by *http*.
>>>
>>>
>>> Is it true? Is the create() only possible if git ist powered by http or
>>> is an another problem possible?
>>>
>>> Thanks Daniel
>>>
>>> --
>>> Supercharge your Review Board with Power Pack:
>>> https://www.reviewboard.org/powerpack/
>>> Want us to host Review Board for you? Check out RBCommons:
>>> https://rbcommons.com/
>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "reviewboard" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> --
>> Christian Hammond
>> President/CEO of Beanbag <https://www.beanbaginc.com/>
>> Makers of Review Board <https://www.reviewboard.org/>
>>
>
--
Supercharge your Review Board with Power Pack:
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons:
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups
"reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.