create commit from plugin

How can one create a commit from within a plugin?

We would like to add an empty commit immediately after creating a branch. Branches are only created through the BitBucket GUI.

An event listener is in place, and the necessary components are succesfully autowired. But the creation of the commit fails with "Caused by: com.atlassian.bitbucket.scm.CommandFailedException: '/usr/bin/git commit -m ebo-bitbuckit-commit --' exited with code 128 saying: fatal: This operation must be run in a work tree"


What are we missing? Or should we try a different route?



public void onRefsChanged(AbstractRepositoryRefsChangedEvent event) {
Repository repo = event.getRepository();
File repoDir = gitScmConfig.getRepositoryDir(repo);

final GitCommitBuilder builder = builderFactory.builder(repo).commit() // create a commit builder
.workingDirectory(repoDir) // run on the correct path
final String sha = SomeOutputHandler()).call();


1 answer

1 vote

Hi David! For this kind of questions, my recommendation would be to post it at, that's where our developer community hangs out :)



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

234 views 3 7
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you