We are using Sonarcloud and trying to use the Sonarcloud API to create a new project that is referenced to a github repository.
A couple of things are happening:
- The project within sonarcloud is not linked to github
- After the initial scanning (using projectkey) there are two branches master (the main) and main
The problem we are having is our github repository has one branch initially… main
Within Sonarcloud we see:
- Long-lived branches - master
- Short-lived branches - main
Why is this happening? also is “linked” repositories only available for “automatic scanning”? we want to use manual scanning.
Basically I am doing the following:
Calling https://sonarcloud.io/api/projects/create
API passing in the following:
- name=RepoName
- project=ourorg_RepoName
- newCodeDefinitionType=previous_version
- newCodeDefinitionValue=previous_version
- organiszation=ourorg
- visibility=private
We then use sonar-scanner
CLI passing in the following:
- sonar.projectKey=ourorg_RepoName
- sonar.organization=ourorg
- sonar.projectVersion=1
- sonar.token=thetoken
- sonar.branch.name=main
- sonar.qualitygate.wait=false
- sonar.host.url=https://sonarcloud.io
How can we make the Long lived branch set to main? or is it always going to be master?
Things seem to be good if we create the project using the Sonarcloud UI… but we cannot use the UI and want to do this programmatically… is this not possible? or am I doing something wrong.