Tips for Using Bitbucket Pipelines for Maven Java Projects

Tips for Using Bitbucket Pipelines for Maven Java Projects

If you are using Bitbucket Pipelines to run continuous integrations for your Maven projects, this post provides some tips.

Create your own Docker image with custom Maven settings

If your project uses private Maven repositories, or you need to customize the Maven settings, you can create a new Docker image based on the official Maven Docker image. See this post for more details.

Maven surefire plugin 2.x issue on OpenJDK 8

If you are using the Maven Docker image based on OpenJDK 8 and Maven surefire plugin, you may encounter an issue that forked JVM crashed without running any test. This is an known issue fixed in surefire plugin 3.0.0-M1. See here for more details. For 2.x version, the workaround is to add <argLine></argLine> to the Maven settings.xml file. This property can be added to any activated profile.


Use protoc-jar-maven-plugin

If you are using protoc-jar-maven-plugin to generate protobuf code, you may encounter errors like below,

caught exception, retrying: Cannot run program "/tmp/protocjar9086668896905207656/bin/protoc.exe": error=2, No such file or directory

To fix this issue, make sure your Maven Docker image is NOT based on Alpine, e.g. using tags like 3.6.0-jdk-8. Some missing libraries in Alpine Linux caused the Maven plugin to fail.

© 2022 VividCode