Closed elboletaire closed 6 years ago
Would it make sense to do the same for the SONAR_GITLAB_PROJECT_ID
- $CI_PROJECT_ID
and SONAR_PROJECT_KEY
- $CI_PROJECT_NAME
? I'm finding I have to include these bindings as well in my .gitlab-ci.yml
files.
Ofc it can be done. The reason why we didn't think about it is because we use different identifiers in sonar than in gitlab.
@albarji this is already available in the develop
tag, could you help us trying it and letting us know if it works as expected for you?
Thanks in advance 😃
Mmm... ok I'm having some issues with the develop version, I'll let you know when it's ready for using it.
Now everything works as expected. So if anyone wanna try... go for it.
Took me some time to check this out. Thanks for the changes!
I'm finding something troubling though. The SONAR_PROJECT_KEY environment variable is now not being processed anymore (as per this commit), so I guess the proper way to deal with this now is to add it to the sonar-project.properties file. My question is: wouldn't it be easier to assign SONAR_PROJECT_KEY=$CI_PROJECT_NAME so that the name of the project is automatically fetched from Gitlab and assigned to a Sonar project with the same name?
We removed it due to #19. The proper way would be using the sonar-project.properties
file (that's how we always have done it), or specifying the param, as it's now possible with the latest changes:
script:
- gitlab-sonar-scanner -Dsonar.projectKey=Whatever
The problem is that there's a lot of people using different ids in CI_PROJECT_NAME and SONAR_PROJECT_KEY. In our case, we use a lot of namespaces and many projects have the exact same name (like 'api' or 'widgets'), which does not fit for our needs. It also was overlapping the field defined in the sonar-project.properties
file, so unless you find a solution... it'll remain this way.
I see, that makes sense. Well, fortunately for my use case I followed your suggestion and used
script:
- gitlab-sonar-scanner -Dsonar.projectKey=$CI_PROJECT_NAME
This worked out perfectly. Thanks a lot!
Automatically define
SONAR_PROJECT_VERSION
from$CI_BUILD_ID
ifSONAR_PROJECT_VERSION
has not been defined by the user (in.gitlab-ci.yml
).More:
SONAR_PROJECT_VERSION
:$CI_BUILD_ID
SONAR_GITLAB_PROJECT_ID
:$CI_PROJECT_ID
SONAR_PROJECT_KEY
:$CI_PROJECT_NAME