Bitbucket-Server: Delete branch programmatically in plugin?

Hi guys,

i am wondering if and how i can delete a branch after merging it programmatically. I tried multiple things but they didn’t work out. So i am wondering if it even is possible via the java api or so.

I need this, because we want do define our own work-flow in bitbucket for our company. This includes a functionality that allows the user to merge all pull-requests from different repositories that have the same “From”->“To” Branches. (pls dont ask why ^^’)

So if anyone can help that would be great.

Yannik

factory.builder(repository).branch().delete(ref).force(true).build().call()

factory is instance GitCommandBuilderFactory
ref is branch name like master

3 Likes

factory is instance GitCommandBuilderFactory

factory.builder(repository) is marked as deprecated in 7.14 (see GitCommandBuilderFactory (Bitbucket Server - Git SCM API 7.14.0 API)).
What is the new Java API?

Thanks in advance.
Cheers.

Hello, it appears they are simply changing the method signature for GitCommandBuilderFactory#build. It used to accept #build(@Nullable Repository repository) but now will only accept #build(@NotNull Repository repository). I think this implies that this is still non-deprecated API but that the method signature will change so that any nulls will explode and you’d have to do null checking prior to passing in a Repository to #build.

1 Like