How to restrict branch creation based on pattern in Bitbucket - bitbucket

I am using Atlassian Bitbucket server v4.8.6.
How do I restrict restrict branch creation based on pattern.
Rules explained below -
Only ABC team should be able to create release/ABC-*
Only XYZ team should be able to create personal/XYZ-*

You can't create rules to prevent only the "creation" of branches. These are the avaliable restrictions:
Prevent all changes
Prevent deletion
Prevent rewriting history
Prevent changes without a pull request
To create branch permissions do the following:
Go to Repository > Settings > Branch permissions > Add permissions
Select "Branch pattern"
Add branch pattern, ex: release/ABC-*
Select one of the restrictions available
Add the group exception, ex: ABC

This can be done by adding "*" on Select branch text field. See the screenshot below.
Go to your repository > Settings > Branch permissions > Add permission
Under "Select branch - By name or pattern", put an asterisk (*)
Save
After that, you can restrict each branch patterns you want for different teams or people.
ABC group
Select branch = release/ABC-*
Write access = ABC group or ABC members
Personal branch
Select branch = personal/XYZ-*
Write Access = Your account

Related

Bitbucket - how to set branch permissions for given source/dest pair?

In Bitbucket cloud it's straightforward to set a branch permission to control who and how changes can be made, for example, consider who can modify the 'main' branch. We need more granularity and would like to be able to set up a rule based on both the source and destination branch.
Imagine we had the following branches:
releaseX
releaseY
featureA
featureB
Is it possible to specify a branching pattern or something that would apply different rules from release* -> main than feature* -> main? Maybe the 'Select branch By pattern' input takes a special pattern like s:release*,d:main etc..? Is this possible?
We also have access to the BB API if that helps somehow.

Using API how to find the parent branch in Bitbucket

I want to find the parent branches for a particular branch. Suppose I have created A branch from master and branch B from A. Now I want to find the parents for B like B->A->Master. I checked the Bitbucket API but there is no such a method available. When I pull the data for a branch there is no field which shows the parent branch details.
You can use regular git commands for that:
git branch --merged HEAD --sort=authordate
This lists the ancestor branches of the current working directory in chronological order (you can of course specify any other ref instead of HEAD) and would be great to use in a script or some automated tooling.
A very quick and dirty alternative way would be to just look at the regular output of git log:
git log --graph --decorate | egrep 'commit .* \('
This variation would maybe be interesting for a human to watch but too noisy for a script.

Choosing prefix name on creating new branch

In our company, we use azure-devops and edited some settings about folder hierarchy (hotfix, feature, bugfix etc.) with this documentation.
We want to choose one of those prefix names and type branch name. For example, I choose feature and type login-page. Branch name will be hotfix/login-page.
I search a lot but don't any result about that. Is there any way to do that?
I choose feature and type login-page. Branch name will be
hotfix/login-page.
If you mean creating a branch name such as hotfix/login-page, then it's not supported. We can only select based on branch but cannot select the folder, that means we cannot create a branch based on a folder.
In your scenario, it will create a new branch called login-pagebranch under the hotfix folder.
That means / here will be identified as the symbol of the folder hierarchy.
If you want to create a branch under the feature folder, then you should type feature/login-page. We cannot select prefix name on creating a new branch.

Add module by condition in Jenkins

I'm trying to make job in Jenkins, that make build any of tags, trunk, branches.
These parameters I added
Choice Parameter named SRC_TYPE with choises tags, branches, trunk
List Subversion tags named PROJECT_TAG with repository URL svn://foo/bar/tags
List Subversion tags named PROJECT_BRANCH with repository URL svn://foo/bar/branches
Now I'd like to add module (subversion) to section Source Code Management that depends on parameters.
I need to set repository URL for this module to
svn://foo/bar/tags/${PROJECT_TAG}/Project for ${SRC_TYPE} == "tags"
svn://foo/bar/branches/${PROJECT_BRANCH}/Project for ${SRC_TYPE} == "branches"
svn://foo/bar/trunk/Project for ${SRC_TYPE} == "trunk"
Is it possible? And how it can be done?
You need version 1.32 of the subversion plugin, as it fixes ISSUE-10678
Once you have that, you can configure Subversion Drop-Down Build Parameter, provide the SVN URL of http://foo/bar and it will list trunk, all branches, and all tags under the dropdown.

TFS - is it possible to delete merge flag from files and send commit just like a normal changeset?

Let's say I have two branches: A and child branch B. I wanna merge one changeset from branch A to B, but with one detail: I don't want flag [merge] for files in this changeset, it must look just like I edit files manualy and don't have a link on changeset from branch A. Is it possible?
Yes, the general idea is to generate a diff on the source branch with the following command
tf.exe diff [...] /recursive /format:unified /version:[...] >> diff.patch
Replace the [...] with the actual values (branch folder and versions). The documentation is on MSDN
Then use the patch utility (from sourceforge.net) to apply it the other branch:
patch.exe -p0 < diff.patch
Then check in.

Resources