Stash API - How do you Fork to a user's account as Admin

seanvoss July 15, 2013

As a System Admin, I'm trying to migrate many user's accounts which currently have forks of upstream repository, how would I go about doing that via the API.

I looked for a way to do it with the fork create request, and didn't see a way to masquerade as user option.

3 answers

0 votes
Sean Voss July 16, 2013

Cool, yea I'm going down that path, I think I have eclipse configured and the sdk installed correctly.

Was checking into the tutorials, to get a feel for coding a plugin.

You feel like sending some links that would relevant to building this project to give me a shove in the right direction?

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

Hi Sean,

I'm always a fan of examples over tutorials:

http://atlassian.bitbucket.org/#stash

There's obviously our dev docs as well:

https://developer.atlassian.com/stash/docs/latest/

Good luck. :)

Charles

0 votes
Sean Voss July 15, 2013

I was hoping to do this using the Rest API, but this is exactly what I had in mind.

I'm looking to migrate a rather large userbase with quite a few Repos & quite a few Forks per Repo (from github) and I'd like to keep the structure intact. That means as far as I can tell, using the Forking creation api, you can only do it either to the user's default, or a project using a KEY.

My plan of attack was what I listed above, but if I have to go to the Java Plugin route, that would be okay whilst slower as I can write Java as well.

What do you think Charles, is there a better way to go about it?

Thanks,

Sean

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2013

Hi Sean,

Thanks for the details.

I think to create the forks themselves you're going to have to use a custom Java pluin just to create the forks. So my advice would be to import the parent repositories (either as a script/REST or Java), and then write a simple plugin that does the forking in Java. You could even just expose 'forkAsUser' as a REST endpoint and then control the rest from a script. Obviously make sure you turn that plugin off when you're done.

Let me know if you get stuck with the plugin. Also, if you can, please post any details/code on your migration as I'm sure others will find it useful. :)

Charles

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

Hi Sean,

If you're talking about doing this in-process as a Java plugin you might be interested in the SecurityService. Is that what you had in mind?

Just out of curiosity what kind of migration are you doing exactly?

Cheers,

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events