Bitbucket Server 8.0 Early Access Program (EAP) release

We are pleased to announce the availability of the first Early Access Program (EAP) release of Bitbucket Server 8.0.

This EAP release is so that app vendors and customers who have written in-house apps can update their apps to ensure they will work with the public release of Bitbucket Server 8.0.

Bitbucket Server 8.0, due in mid-April 2022, is our next platform release and will contain breaking changes .

Important things to note about this EAP release:

  • As development of the release is underway, the specifics of breaking changes will evolve and there may be other minor API changes between this release and the public release of Bitbucket Server 8.0.
  • This release should not be used in production environments . For all production use and testing of Bitbucket Server, please use the latest official release instead.

Download the EAP

Overview of changes in the EAP

Bitbucket Mesh

Bitbucket Mesh - distributed, replicated, and horizontally scalable Git repository storage system for higher performance and better resilience. Admins can setup Mesh nodes and start migrating repositories from shared file system to Mesh for testing and evaluation.

End of Windows support

Microsoft Windows has always been an inferior platform for hosting Bitbucket Server when compared to Linux. Disk I/O and process forking performance is poor on Windows and this impacts Bitbucket’s performance. As a result, we have never supported Data Center licenses or licenses with more than 500 users on Windows.

Bitbucket 8.0 will not support hosting on the Windows operating system. For app developers running Windows, we recommend running Bitbucket from within Windows Subsystem for Linux or in a virtual machine.

Other supported platform changes

Support for the following has been removed:

  • Databases
    • PostgreSQL 9.4, 9.5 and 9.6
    • MySQL 5.5 and 5.6
    • MariaDB 5.5, 10.0, 10.1 and 10.2
    • Microsoft SQL Server 2012
    • Oracle 11g and 12c R1
  • Git (the minimum supported Git version, for the server installed version, is now 2.31)
    • Git 2.11 thru 2.30
  • Elasticsearch (the new minimum supported version is 7.10)
    • 5.5, 6.5, 6.6, 6.8, 7.5 and 7.9

Migrate H2 database to MvStore format

If you are upgrading to Bitbucket 8.0 and use H2 as the database, you need to follow the steps given below for migrating your database file to the supported format. You need to perform these steps before starting Bitbucket on 8.0 -

  • Make sure the Bitbucket application is not running.
  • Change to your <Bitbucket Server installation directory>/bin and use the command BITBUCKET_HOME=<Home directory> ./h2-migrate-db-file.sh . Please make sure that one of the JAVA_HOME or JRE_HOME environment variables are set before running this command.
  • There are some additional environment variables you can set for customizing the behaviour of the script -
    • BITBUCKET_SHARED_HOME - Set this variable only if the shared home is different from <BITBUCKET_HOME>/shared . Note that you don’t need to set BITBUCKET_HOME if you set this variable.
    • DB_FILE - Set this variable only if you want to provide a custom location for the H2 database file. <BITBUCKET_SHARED_HOME>/data/db.h2.db is used by default if this variable is not set.
    • H2_JAR_PATH - This variable is optional and can be used to set the path of the H2 jar file. The H2 jar bundled in the installation directory is used by default.
    • JDBC_USER - This variable is optional and can be used to set the username to connect to the H2 database file. The default username is sa .
    • JDBC_PASSWORD - This variable is optional and can be used to set the password to connect to the H2 database file. The default password is blank (“”).

Deprecated Java APIs removed

Interfaces, classes, and methods in the Bitbucket Server Java API that were previously marked as deprecated have been removed.

Plugins that use any of these interfaces (which would have generated deprecation warnings when built against Bitbucket Server 7.x) generally won’t build with Bitbucket Server 8.x

Precompiled plugins that used any of the removed interfaces will fail to install or run in Bitbucket Server 8.x, typically with java.lang.NoSuchMethodError or java.lang.ClassNotFoundExceptions .

ScmCommandBuilder changes and the GitWorkTree API

Bitbucket 8.0 includes changes to support Bitbucket Mesh, which uses replication to provide scaling and high availability. Bitbucket needs to have strict control over updates to repositories to ensure all replicas are updated in sync. Several commands that could earlier be invoked using ScmCommandBuilder can no longer be used directly starting in 8.0. The following is a comprehensive list of such commands:

"add", "apply", "bisect", "checkout", "checkout-index", "citoool", "clean", "clone", "commit", "commit-tree", "config", "credential", "credential-cache", "credential-store", "daemon", "fast-import", "filter-branch", "gc", "gui", "imap-send", "init", "init-db", "instaweb", "ls-files", "merge-file", "merge-index", "merge-one-file", "merge-tree", "prune", "read-tree", "reflog", "reset", "restore", "rm", "stash", "send-email", "show-index", "sparse-checkout", "status", "submodule", "switch", "web--browse", "update-index", "worktree", "write-tree"

Some of the commands in the above list will be restricted in Bitbucket 8.0 to prevent changes that could break the replication mechanism. Other commands only make sense in non-bare repositories and will only be supported in the context of a GitWorkTree . The GitWorkTree API was introduced in Bitbucket 7.14 and there is an introduction to the API in the Bitbucket 7.14 API changelog.

Removed API and REST resources related to Task s

In Bitbucket 7.2, Task s were replaced with “blocker comments” in order to support top-level tasks and tasks with rich text. Details on affected classes and migration guidance can be found in the Bitbucket 7.2 API changelog.

Change in return type of RepositoryDeletedEvent.getForkIds and RepositoryDeletionRequestedEvent.getForkIds

Both these classes returned an Iterable<Integer> and have been changed to return Set<Integer> for ease of use.

Replaced Bitbucket auditing API with cross-product auditing API

Bitbucket 7.0 introduced a new cross-product audit log that captured more events and more information about each event. It also introduced a new API for auditing events (and a new REST API for retrieving auditing events from the database) and deprecated the Bitbucket’s old auditing API (mostly contained within the com.atlassian.bitbucket.audit package).

Bitbucket 8.0 removes the old audit API which includes classes in com.atlassian.bitbucket.audit and a number of other classes that converted between the old system and the new system. :Important: Bitbucket 8.0 also removes the old legacy REST API for getting audit events by project or repository.

Details on the cross-product auditing log and a short introduction to the new API can be found in this post to the Atlassian developer community.

Removed API details

The following classes and interfaces have been removed in Bitbucket Server 8.0. Please see the linked Javadoc for Bitbucket Server 7.21 for informing regarding deprecation and possible alternative classes and interfaces.

  • AvatarDeletedException
  • BuildStatus
  • BuildStatusService
  • BuildStatusSetEvent
  • BuildStatusSetRequest
  • BuildSummary
  • RestDetailedRepository
  • RestDetailedRepositoryPage
  • TaskEvent and subclasses ( TaskCreatedEvent , TaskDeletedEvent , TaskUpdatedEvent )

In addition, deprecated methods in existing classes and interfaces across the whole Bitbucket Server API have been removed:

  • NavBuilder methods related to the Jira commit checker and the old way of building attachments.

Consult the Bitbucket Server 7.21 Java API Reference for details on the removed methods, and their alternatives in Bitbucket Server 8.x.

Deprecated frontend APIs removed

In Bitbucket 7.0, we redesigned the pull request experience to bring a slew of new features and better performance.

Bitbucket 8.0 introduces the same experience to other areas in Bitbucket where we show code diffs: the commit diff page, the create pull request page and the branch compare page. As a result, plugin points on these pages will no longer render. Frontend plugin points on these pages will need to change, similar to what was required for the original pull request update.

Known issues

  • There is currently a bug in the Web Resource Manager that means some plugin internationalization may not work as expected. The workaround to this bug is documented in this post in our developer forums.
5 Likes

Hey Kristy @khughes

Thanks for Bitbucket 8 EAP!

We tried to get our apps against Bitbucket 8.0.0-eap05 working with atlas-debug, but encountered the following issues:
Without any homezips, we get the following exception:

[INFO] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshHealthcheck' defined in URL [jar:file:/project/target/bitbucket/app/WEB-INF/lib/bitbucket-git-mesh-8.0.0-eap05.jar!/com/atlassian/stash/internal/scm/git/mesh/MeshHealthcheck.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshClient' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'meshClient' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routePropagatingClientInterceptor' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'routePropagatingClientInterceptor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshRouter' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'meshRouter' parameter 5; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sidecarManager': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to start Mesh
[INFO]  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
[INFO]  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
[INFO]  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
[INFO]  at javax.servlet.GenericServlet.init(GenericServlet.java:158)
[INFO]  at java.lang.Thread.run(Thread.java:748)
[INFO]  ... 18 frames trimmed
[INFO] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshClient' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'meshClient' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routePropagatingClientInterceptor' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'routePropagatingClientInterceptor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshRouter' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'meshRouter' parameter 5; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sidecarManager': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to start Mesh
[INFO]  ... 6 common frames omitted
[INFO] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routePropagatingClientInterceptor' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'routePropagatingClientInterceptor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshRouter' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'meshRouter' parameter 5; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sidecarManager': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to start Mesh
[INFO]  ... 6 common frames omitted
[INFO] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'meshRouter' defined in com.atlassian.stash.internal.scm.git.GitWiring$MeshWiring: Unsatisfied dependency expressed through method 'meshRouter' parameter 5; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sidecarManager': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to start Mesh
[INFO]  ... 6 common frames omitted
[INFO] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sidecarManager': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to start Mesh
[INFO]  at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)
[INFO]  ... 5 common frames omitted
[INFO] Caused by: java.lang.IllegalStateException: Failed to start Mesh
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.DefaultSidecarManager.startSidecar(DefaultSidecarManager.java:166)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.DefaultSidecarManager.start(DefaultSidecarManager.java:109)
[INFO]  ... 5 common frames omitted

Any idea what is wrong here?

And if we try to use our homezips from Bitbucket 7, we get:

[INFO] 2022-03-22 12:01:26,283 INFO  [main]  c.a.b.i.boot.log.BuildInfoLogger Starting Bitbucket 8.0.0-eap05 (7fdf0d8 built on Tue Mar 22 01:47:32 CET 2022)
[INFO] 2022-03-22 12:01:26,284 INFO  [main]  c.a.b.i.boot.log.BuildInfoLogger JVM: Private Build OpenJDK 64-Bit Server VM 1.8.0_252-8u252-b09-1ubuntu1-b09
[INFO] 2022-03-22 12:01:31,068 INFO  [spring-startup]  c.a.s.internal.home.HomeLockAcquirer Successfully acquired lock on home directory /project/target/bitbucket/home
[INFO] 2022-03-22 12:01:31,087 INFO  [spring-startup]  c.a.s.internal.home.HomeValidator Upgrading Bitbucket from 7.0.0 to 8.0.0
[INFO] 2022-03-22 12:01:33,275 WARN  [spring-startup]  o.s.w.c.s.XmlWebApplicationContext Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'crowdAliasDao': Unsatisfied dependency expressed through method 'setSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sharedHomeLockAcquirer' defined in class path resource [stash-context.xml]: Cannot resolve reference to bean 'licenseHelper' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'licenseHelper' defined in URL [jar:file:/project/target/bitbucket/app/WEB-INF/lib/bitbucket-service-impl-8.0.0-eap05.jar!/com/atlassian/stash/internal/license/DefaultLicenseHelper.class]: Unsatisfied dependency expressed through constructor parameter 3; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'databaseSupplier' defined in URL [jar:file:/project/target/bitbucket/app/WEB-INF/lib/bitbucket-dao-impl-8.0.0-eap05.jar!/com/atlassian/stash/internal/db/DefaultDatabaseSupplier.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [stash-context.xml]: Cannot create inner bean 'dataSourceFactory$created#4530328d' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceFactory$created#4530328d' defined in class path resource [stash-context.xml]: Cannot resolve reference to bean 'dataSourceConfiguration' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceConfiguration' defined in class path resource [stash-context.xml]: Cannot create inner bean 'dataSourceConfigurationFactory$created#3568770' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceConfigurationFactory$created#3568770' defined in class path resource [stash-context.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.atlassian.stash.internal.jdbc.DataSourceConfiguration]: Factory method 'create' threw exception; nested exception is com.atlassian.stash.internal.jdbc.UnsupportedH2StoreException: H2 DB file format is no longer supported

What is the H2 jdbc url used by default in Bitbucket 8?
Is it related to PageStore and MVStore changes in H2? java - What's the recommended way to migrate from H2 1.3.175 to 1.4.195 - Stack Overflow

Thanks a lot
Markus - Mibex Software

1 Like

I just had this, try checking the logs specifically for Bitbucket Mesh, they are present in mesh/log/atlassian-mesh.log within the Bitbucket home directory.

In my case the problem was that my Git version was not supported by Mesh.

2 Likes

@rlander Thx for the pointer.
As reference for others:
https://confluence.atlassian.com/bitbucketserver080/set-up-and-configure-mesh-nodes-1115143198.html

I also found the used H2 jdbc url: jdbc:h2:/project/target/bitbucket/home/shared/data/db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE

But may last question from above still open. So any hint there is welcome. thx.

1 Like

Hi @MarkusSutterMibexSof ,

You can use following steps to fix the issue with H2 database -

  1. Make sure that the Bitbucket application is not running.
  2. Change to your <Bitbucket Server installation directory>/bin and use the command BITBUCKET_HOME=<Home directory> ./h2-migrate-db-file.sh. Please make sure that one of the JAVA_HOME or JRE_HOME variables are set before running this command.

Please let us know if you run into issues with the migration of H2 database.

1 Like

Hi

I get the ‘H2 DB file format is no longer supported’ on a ‘clean’ instances with atlas-run-standalone:

  1. I run atlas-run-standalone --product bitbucket --version 8.0.0-eap05
  2. It starts, but http://localhost:7990/bitbucket shows a failed startup screen.
  3. In the log/atlassian-bitbucket.log, I see the failed startup:
    Factory method 'create' threw exception; nested exception is com.atlassian.stash.internal.jdbc.UnsupportedH2StoreException: H2 DB file format is no longer supported

I would expect that this command line starts with no database, but that doesn’t seem to be the case. Is there a way start a clean instance with atlas-run-standalone?

The Atlassian SDK is 8.2.7, which seems to be the latest.

2 Likes

@RomanStoffel,

I would expect that this command line starts with no database, but that doesn’t seem to be the case

AMPS starts the system with a set of test data installed, unless explicitly configured not to. Add --data-version=8.0.0-eap05 to ensure the system starts up using data from the same version of Bitbucket you’re testing with. It should start without issues, then, since that test data uses an MVstore database.

Best regards,
Bryan Turner
Atlassian Bitbucket

2 Likes

Hey Kristy @khughes

Thanks for the Bitbucket 8 EAP!

In one of our apps we’re using the Bitbucket Markdown renderer lib com.atlassian.bitbucket.markup.
In the JavaDocs I see that it got removed without any replacement: MarkupService (Bitbucket Server - API 7.21.0 API)

Can you please tell me what we should use instead, is it the Atlassian Markdown renderer lib? https://mvnrepository.com/artifact/com.atlassian.markup

Would be great if we can render Markdown in apps the same way as Bitbucket does it.

Thanks,
Michael

3 Likes

Hello

We’ve found API compatabilities issues between the 7.x and the 8.0.0-eap version in the CommandOutputHandler API.
Which means that our app can’t be compiled to run with 7.x or 7.21.0 and also run in 8.0.0-eap.

In the GitWorkTree, the builder API will create a command in the end, and that requires a ‘CommandOutputHandler’

CommandOutputHandler outputHandler = ...
workingDir.builder()
   // build up command
   .build(outputHandler)

However, the CommandOutputHandler has a incompatible signature between 7.21.0 and 8.0.0-eap05. The signature of the setWatchdog changed:

In 7.21.0 and the 7.x series it is:
void setWatchdog(com.atlassian.utils.process.Watchdog watchdog).

In the 8.0.0-eap it is:
void setWatchdog(com.atlassian.bitbucket.scm.Watchdog watchdog).

Also, the whole inherited interfaces moved:

In 7.21.0 and the 7.x series it is:
CommandOutputHandler inherits com.atlassian.utils.process.OutputHandler

In the 8.0.0-eap it is:
CommandOutputHandler inherits com.atlassian.bitbucket.scm.CommandOutputHandlerSupport, com.atlassian.bitbucket.scm.CommandOutputHandlerSupport

This then makes the app compiled against 7.21.0 not run in 8.0.0, because the it wires to the wrong OSGII packages. And probably would fail at runtime later:

[INFO] Caused by: org.osgi.framework.BundleException: Unable to resolve ch.mibex.stash.templates [146](R 146.0): missing requirement [ch.mibex.stash.templates [146](R 146.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.utils.process) Unresolved requirements: [[ch.mibex.stash.templates [146](R 146.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.utils.process)]
[INFO]  at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149)
[INFO]  ... 52 common frames omitted

It would be great if its possible to be able to compile the app to run across 7.x and 8.x.
Is there a way to fix this?
The only way at the moment seems to ship a separate version for 7.x and 8.x?

Update Number 2:
We found that there is the com.atlassian.bitbucket.server/bitbucket-scm-common provided dependency, which has a LineReaderOutputHandler and SingleLineOutputHandler.
The provided implementation at runtime does implement the CommandOutputHandler in a compatible matter. So, we use the SingleLineOutputHandler or extend from LineReaderOutputHandler in our app, and then it works =).

This is better for us than the reflection based approach. If you can’t use these classes, you might still can go the reflection route: Check the edit history of this post for our previous solution.

Cheers
Roman

@RomanStoffel,

We are removing process utils from the system, as it’s no longer used to run processes. Unfortunately, there is no “compatible” way we can remove the process utils APIs. This does mean apps that wish to support 7.x and 8.x and use the builder APIs will need to release separate versions for each major line which are compiled against the relevant API versions.

I’m sure that’s not the answer you’re hoping for. My apologies for the hassle. I’ll note that it’s something we’re dealing with internally for our own apps, like the Bitbucket Cloud Migration Assistant.

Best regards,
Bryan Turner
Atlassian Bitbucket

2 Likes

@bturner Thanks for the answer. It is the answer I expected =).
I wanted to double check that it isn’t an oversight. Or that there is a good way to avoid / work around this breaking change.

We’ll have to discuss with our team on how we will deal with it. Most likely we’ll have to maintain two flavors of the app for 7.x and 8.x.

@bturner Do you have any hint about that Markup support? Thx.

Hey @khughes, @bturner

Thanks for the Bitbucket 8 EAP!

In app Awesome Graphs for Bitbucket we’re using the com.atlassian.bitbucket.throttle.ThrottleService and ScmCommandBuilder (commands “diff-tree”, “log”, “rev-list”, “show-ref”) like this

    public void streamFiles(Repository repository, String commitId, Consumer<AffectedFile> consumer) {
        try (Ticket ignore = throttleService.acquireTicket("scm-command")) {
            Command<Void> command = scmService.createBuilder(repository)
                    .command("diff-tree")
                    .argument("--no-commit-id")
                    .argument("--numstat")
                    .argument("-M")
                    .argument("-r")
                    .argument("-z")
                    .argument(commitId)
                    .build(new CommitFilesOutputHandler(consumer));

            command.call();
        }
    }

In the JavaDocs I see that it got removed without any replacement: ThrottleService (Bitbucket Server - API 7.21.0 API)

Can you please tell me what we should use instead?

2 Likes

Hi @michael.rueegg, thanks for raising the markup issue. We’re going to be re-adding MarkupService into the API, so it won’t be removed in the final version of 8.0

3 Likes

Hi @yorlov, due to the change in how Bitbucket interacts with Git (i.e. the introduction of Bitbucket Mesh) throttling is no longer actually done by Bitbucket itself, but by the Mesh node. Plugins no longer need to handle throttling themselves as Mesh will do it for them, but the same ResourceBusyException will be thrown if it’s out of tickets. As an example, you can take a look at what we did in the Bitbucket Auto-unapprove plugin that we maintain here.

3 Likes

@khughes That’s great news, thanks for the feedback!

We encounter more issues with the GitWorkTree API.

Our Repository Templates app copies a template repository into a newly created repo. We’ve ported the code to the WorkTreeApi, and it does work on Bitbucket 7 (with small limitations)

However, when running on Bitbucket 8, the code fails with the GitWorkTree api.
The GitWorkTree api requires a ‘expectedHash’ to publish a change.
We publish to a empty repo with no commits yet, so we used a ‘all-zero’ SHA, as git tooling does accept:

    String noExistingCommit = "0000000000000000000000000000000000000000"
    newRepoWorkspace.publish(
      new PublishGitWorkTreeParameters.Builder(invoker)
        .author(author)
        .branch('master', noExistingCommit)
        .build())

This works in Bitbucket 7. However, in Bitbucket 8 it fails:

[INFO] com.atlassian.bitbucket.commit.NoSuchCommitException: Commit '0000000000000000000000000000000000000000' does not exist in repository 'b2'.
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.DefaultErrorTranslator.translateNoSuchCommit(DefaultErrorTranslator.java:325)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.DefaultErrorTranslator.translate(DefaultErrorTranslator.java:119)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.WorkTreeErrorTranslator.translateMaybeWorkTree(WorkTreeErrorTranslator.java:59)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.WorkTreeErrorTranslator.maybeTranslate(WorkTreeErrorTranslator.java:39)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.AbstractFutureResponseObserver.maybeTranslate(AbstractFutureResponseObserver.java:203)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.AbstractFutureResponseObserver$ResponseFuture.translateCause(AbstractFutureResponseObserver.java:292)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.AbstractFutureResponseObserver$ResponseFuture.get(AbstractFutureResponseObserver.java:229)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.AbstractFutureResponseObserver.asResult(AbstractFutureResponseObserver.java:145)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.PublishWorkTreeResponseObserver.asResult(PublishWorkTreeResponseObserver.java:58)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.PublishWorkTreeResponseObserver.asResult(PublishWorkTreeResponseObserver.java:14)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.AbstractFutureResponseObserver.asResult(AbstractFutureResponseObserver.java:133)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.GrpcGitWorkTreeClient.publish(GrpcGitWorkTreeClient.java:95)
[INFO]  at com.atlassian.stash.internal.scm.git.mesh.worktree.MeshGitWorkTree.publish(MeshGitWorkTree.java:146)

So, my question is, how should be publish branches into a empty repository, where there isn’t a previous commit available?

2 Likes

@RomanStoffel,

So you’re trying to pass the null SHA (By the way, have you seen ShaUtils.NULL_SHA1?) as the expected hash to enforce that the system must create a new ref? (Note that that doesn’t really have anything to do with an “empty” repository; it’s 100% about telling Git “You must be creating a new ref.” You can use it in a non-empty repository and it’ll work fine.)

I’m not able to reproduce the issue with the current Bitbucket Server 8 code. I’ve tried it creating a new branch in an existing repository:

        workTreeBuilderFactory.builder(repository)
                .execute(workTree -> {
                    workTree.write(filePath, UTF_8, callback -> callback.write(fileContent));
                    commitFile(filePath, committerEmail, commitMessage, workTree);

                    workTree.publish(new PublishGitWorkTreeParameters.Builder(hookInvoker)
                            .branch("newly-published-branch", ShaUtils.NULL_SHA1)
                            .build());
                    return null;
                });

And creating a new branch in an empty repository I’ve just created. In both cases it works without issue. Are you passing the null SHA in any places other than the expectedHash on the branch call on PublishGitWorkTreeParameters.Builder?

Have you looked in $BITBUCKET_HOME/mesh/log/atlassian-mesh.log to see if there are any further details on the Mesh side?

In your POM you might try changing 8.0.0-eap05 for 8.0.0-rc2 and see if that changes anything; in addition to Bitbucket Server, that will use a newer build of Mesh. With that said, though, I’m not aware of any changes in Mesh between the milestone included in eap05 and the one in rc2 relevant to this.

You may need to provide us with a more complete reproduction recipe so we can get to the bottom of this.

Best regards,
Bryan Turner
Atlassian Bitbucket

Hey @bturner

Thanks for your response.

Where can we get notified about new EAP versions, like the rc2 you mention?
Actually I would have expected it here. But even in the provided link, https://www.atlassian.com/software/bitbucket/download-eap, it only shows the eap05.

Best regards
Markus - Mibex Software

@MarkusSutterMibexSof,

EAP5 is the newest (and final) EAP. RC2 is an internal build deployed that is currently deployed to our production cluster as we draw closer to the final 8.0.0 release. It’s not packaged as an EAP (there are no installers or other distributions–Edit: That shades the truth slightly; they’re not packaged, but they can be downloaded if you know the URLs to use), but the artifacts from it can be consumed by Maven if an app developer wishes to compile against them.

Best regards,
Bryan Turner
Atlassian Bitbucket