How to rename a project in SonarQube 5.1?

2019-02-12 14:16发布

I can't find how to rename a project in SonarQube 5.1.

Once created, how one can change project name, key, branch, from the web dashboard?

SonarQube's documentation doesn't help.

5条回答
干净又极端
2楼-- · 2019-02-12 14:48

If you are using jenkins and your sonar build is a post build step. You may add the property mentioned by @adrianko to your goals.

$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.projectName="YOUR PROJECT NAME"
查看更多
何必那么认真
3楼-- · 2019-02-12 14:52

You need to "update the project key" (I always think that the Sonar terminology here isn't very helpful)

https://docs.sonarqube.org/display/SONAR/Project+Settings#ProjectSettings-UpdatingProjectKey

and then re-run the analysis (with the new project key, so having updated your sonar-project.properties or build.xml or pom.xml, etc)

查看更多
The star\"
4楼-- · 2019-02-12 15:02

In SonarQube 5.1 the project name can't be changed from the web dashboard (Probably it will not be possible in the future as well).

I configure my SonarQube projects sonar-project.properties where I only have to change this line:

sonar.projectName=MyNewProjectName

Rerun the analysis to see the result in the web dashboard.

查看更多
姐就是有狂的资本
5楼-- · 2019-02-12 15:06
CREATE PROCEDURE usp_ChangeProjectName
    @CaseSensitiveProjectKeyToChange VARCHAR(300),
    @NewProjectName VARCHAR(300)
AS
BEGIN
    SET NOCOUNT ON;

    IF (SELECT COUNT(*) FROM dbo.projects WHERE kee = @CaseSensitiveProjectKeyToChange and scope = 'PRJ') > 1
    BEGIN
    RAISERROR ('Operation would affect more than one record, cancelling for safety.', 16, 1)
END

UPDATE 
    dbo.projects
SET 
    name = @NewProjectName,
    long_name = @NewProjectName 
WHERE 
    kee = @CaseSensitiveProjectKeyToChange and
    scope = 'PRJ'   
END
GO

Sample Usage usp_ChangeProjectName2 '<project key>', '<new name>'

查看更多
唯我独甜
6楼-- · 2019-02-12 15:07

To change the projet name in UI run this SQL query :

UPDATE sonar.projects
SET  name = 'NEW_PROJECT_NAME',
long_name = 'NEW_PROJECT_NAME'
WHERE kee = 'PROJECT_KEY'
查看更多
登录 后发表回答