Create project in SonarCloud with custom projectKey through Bitbucket Pipelines

Hi!

This question is related to: Projectkey without organization name in SonarCloud

What I need to know is if there is a way of chosing the projectKey in the moment of the creation of the project.

This project is created in bitbucket pipelines using mvn sonar:sonar with a custom projectKey that does not contain the organization name on it.

If I try to execute the command withouth first creating the project manually in SonarCloud it fails.

It works if I create the project manually and then I update the projectKey manually in SonarCloud to what I want.

It works also if I execute the command locally in my computer and not in the Bitbucket Pipelines environment (it creates the project in SonarCloud correctly with the custom project key)

Is there a way of creating the project with a custom projectKey in the Bitbucket Pipelines environment directly? We are migrating from Sonarqube to SonarCloud and we were doing this automation before.

Thanks!

Hey there.

You would need to make sure that the user running analysis has the Create Projects permission in your organization, but warning (:warning:) you will not benefit from bound projects, meanign features like Pull Request Decoration won’t work.

1 Like

Ah ok thanks!! Then I will learn how to live with the organization name there because I dont want to lose the rest of the features xD

Many thanks!!

Don’t forget you can change the project key (project Administration > Update Key)

So if I create the project manually in the website with the default projectKey and then I update it to my custom value, I won’t lose the benefits of bound projects?

Correct. The project key is just a unique identifier, which is automatically generated because most users are fine with the default value. The binding is something separate, and isn’t lost if you change the project key.

1 Like

Great then many thanks!! I will proceed like that :slight_smile:

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