It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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?

 

Code:

@EventListener
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
.author(event.getUser()).committer(event.getUser()).message("ebo-bitbuckit-commit");
final String sha = builder.build(new SomeOutputHandler()).call();

 

1 answer

1 vote
Ana Retamal Atlassian Team Jun 01, 2017

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

Regards,

Ana

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

4,061 views 4 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you