First, this question is regarding the Adaptavist ScriptRunner for Bitbucket Server plugin. I tried to tag this question with the proper tag.
My organization is migrating to Bitbucket Server, and we will soon be having many repositories that users will be contributing to.
It appears that as of Bitbucket Server version v4.14.0, it is not possible to specify default settings for all new repositories created within a project. All new repos (and even forked repos) look to take on the default settings chosen by Atlassian.
We would like to be able to have in each of our Bitbucket projects a ‘settings template’ repo. Then, every new repo created in this project would get its settings copied from the ‘settings template’ repo. (I am fine with the 'template' living somewhere else.)
These settings would include, for example:
Repo permissions, Branch permissions, Access keys, Hooks, Pull requests, Branching model, Default reviewers, and any settings from Add-Ons (if possible).
So, would this be possible when using the Adaptavist ScriptRunner for Bitbucket Server plugin? It appears that I would want to trigger on both the "RepositoryCreationRequestedEvent" and "RepositoryForkRequestedEvent".
Otherwise, propagating the settings we need becomes a very manual and error prone process, it would be great to have a programmatic way to achieve this instead.
I personally don't have any experience with java or groovy, so I would probably need a bit of direction. But first, I would like to know if this is possible with ScriptRunner.
Thank you, Jimmy
This is possible with quite a bit of code though. Just wanted to clarify a bit. Whenever a repository is created the event handler would copy all the repository settings etc based on another pre-existing repository?
We already have a built-in admin script which clones a repository here. It sounds like this is quite similar but just an event handler version of it?
It sounds like this is something we could build into the product for you, as I see this being very useful to automate standardisation across repositories.
Thank you, Adam. This is really good news and will help us standardize across many repos.
To your question, yes, we would like all newly created and newly forked repos to take on the settings based on a pre-existing repo ('template').
Somehow I had missed the 'Clone Repository' built-in script when I looked over the 'Admin Scripts' page. Would an event handler based version act any different?
Do you have a similar admin script for forks as well? We noticed when forking repos that the forked repo had Atlassian's default settings.
Also to clarify, the 'Clone Repository' built-in script copies only the items given in the list "The following configuration items are replicated in the new repository" on this page? I see some items missing, for example, merge strategy under pull requests, and hooks.
Finally, would we be able to override repository settings for existing repos beased on the same template?
Thank you! --Jimmy
We don't have an option to clone as a fork at the moment. I can see that it would be useful to have the same settings in the fork when it's created automatically.
An event handler version would automatically set the settings whenever a user created a new repository. The current version requires an admin to manually run the script to clone the repository first instead.
This was written some time ago before merge strategies and the additional pull request options were in Bitbucket. We're currently working on SRBITB-193 which will address this for you with it being released early next week.
I think there are two problems here:
Have you given any thought about how to keep them in sync? For example if the template settings change you'd want that to be reflected in all the repositories that have the template applied? It sounds like from your last question you don't want this and want to override them if necessary?
Hi Adam, thanks so much for this information. I think we would be just fine to have an admin manually run the built-in script rather than using something custom. I'm happy to see that the additional pull request options will be copied across as well!
Our use of forks will be less, but nevertheless would be interested to see if this capability is added to the built-in script in the future.
For the overrides, I hope that our need for this is very limited once our workflow is established. If the template settings change, we may not want that change to be reflected in all repositories, it would be nice to handle it on a case-by-case basis.
Thanks again for your answers!
Good day members, Not sure if you are aware that Atlassian will be hosting a Government Symposium on May 1st, 2019 in Washington DC. For more details please click here If you have any questions...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs