After a recent update to Elasticsearch 7 in Bitbucket 7.1.0, the default elasticsearch-env file within the directory $BITBUCKET_INSTALL/elasticsearch/bin has changed, making it so that the bundled Elasticsearch instance will not start up unless the environment variable JAVA_HOME has been set. This is because Elasticsearch's new backup Java location, if JAVA_HOME is not detected, is a bundled JDK that isn't actually present at $ES_HOME/jdk/bin/java.
- Install or upgrade to Bitbucket 7.1+
- Ensure that the JAVA_HOME environment variable has not been set
- Attempt to start up Bitbucket and Elasticsearch by manually executing the file $BITBUCKET_INSTALL/bin/start-bitbucket.sh
Both Bitbucket and Elasticsearch use the bundled JRE located at $BITBUCKET_INSTALL/jre
The startup script successfully launches Bitbucket, but on attempting to launch Elasticsearch the following error is thrown in the console:
In previous versions of Elasticsearch, on not detecting JAVA_HOME it instead used the command which java to find an alternative Java location. However, in the later versions of this elasticsearch-env file the logic there uses a static location based on the $ES_HOME:
Set the environment variable JAVA_HOME to point to either the standard Bitbucket bundled JRE, or the Java home of a supported Java version.
Alternatively, it's also possible to modify the logic in the file $BITBUCKET_INSTALL/elasticsearch/bin/elasticsearch-env to use a different/correct Java location. However, it's important to note that any changes to this file will be overwritten on performing an upgrade of Bitbucket and these changes will then need to be reapplied.