Sonarcloud analysis in pipelines (java 8 + java 11)

Fred Puistaja November 26, 2020

Our project uses Gradle + Java 8. At the moment it's not possible to migrate over to Java 11.

SonarCloud needs Java 11.

Does anyone know how to setup Bitbucket pipelines where Java 8 is used for building our project and Java 11 is used for SonarCloud analysis?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2020

Hi Fred,

For every step you define in your bitbucket-pipelines.yml file, a Docker container starts, the repo is cloned in that container and then the commands of the script are executed.

If you don't define an image for the Docker container, then the default one (atlassian/default-image:2) will be used.
It is possible to define which Docker image you want to use either at the global level or at the step level (so each step can run on a different image).

What you can do is
- create a step for your build, and for this step use a Docker image that has Java 8
- create another step for SonarCloud analysis, and for this step use a Docker image that has Java 11

We support public and private Docker images including those hosted on Docker Hub, AWS, GCP, Azure and self-hosted registries accessible on the internet.

If you need in the SonarCloud analysis step any files that were generated during the build in the previous step, you can define them as artifacts so that these files will be available in the next step:

If you don't need that and the second step is not dependant on the first one, you can also run these two steps as parallel ones.

If you have any questions and/or need more information about my suggestions, please feel free to let me know.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events