Configure MonoRepo with Bitbucket Cloud

Hi, I may be misreading the docs regarding setting up a MonoRepo with Bitbucket cloud. Both the instructions and the blog post mention adding the project key to your CI pipeline.

Using bitbucket pipes, I cannot see anyway to do this, the only open I get is a unique sonar-token for each project? I was expecting a single access token and then a configurable key, this would be much easier to configure in the build pipeline as we could use the folder name, etc as the key. Currently we have to manually add a repository variable for each sonar project to store the unique key.

Have I missed something.

Partially answering my own question:
With the sonar scanner, you can use the same SONAR_TOKEN value for all projects and specify a different project key, it would be helpful if the documentation reflected this or you were provided a single token for all projects?

Hi there.

When configuring a monorepo you will have to make sure you specify the project key. Using the Bitbucket Pipe, you can pass the project key like this;

- pipe: sonarsource/sonarcloud-scan:1.2.1
      EXTRA_ARGS: '-Dsonar.projectKey=colinmuellerbbc_myRepo -Dsonar.organization=colinmuellerbbc'

Thanks @Colin , am I right in thinking I can reuse the “SONAR_TOKEN” from another “project” and specify the key. This appears to work

Hey @John_Lister

I’ll quote the sonarsource/sonarcloud-scan README which I think answers your question.

Variable Usage
SONAR_TOKEN (*) SonarCloud token. It is recommended to use a secure repository or account variable. And in this case there is no need to specify this variable in the bitbucket-pipelines.yml file.

So using a variable defined at the workspace level should be fine.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.