Search code examples
batch-fileunixsonarqubesonarscanner

sonar scanner quality profile assignment using windows batch file


I'm trying to assign quality profile to a project created in Sonar qube using a batch script. It was working perfectly fine when using shell script in Unix

curl -u <token>: -X POST "http://sonarqube-qa.it.company.net:9000/api/qualityprofiles/add_project?profileName=TEST%E2%80%93MSBI%E2%80%93SSIS&projectName=%project_name%&projectKey=%project_key%&language=xml"

Name of quality profile:-

TEST-MSBI-SSIS

Error message when executing the batch script, which is working fine when executing unix shell script.

{"errors":[{"msg":"Quality Profile for language 'xml' and name 'TEST803MSBI803SSIS' does not exist"}]}

What is the windows equivalent of %E2%80%93 to replace '-' as in Unix


Solution

  • As per my comment:

    From a batch file, you should double all % characters, except for those surrounding your variables, %project_name% and %project_key%.

    For instance:

    curl -u <token>: -X POST "http://sonarqube-qa.it.company.net:9000/api/qualityprofiles/add_project?profileName=TEST%%E2%%80%%93MSBI%%E2%%80%%93SSIS&projectName=%project_name%&projectKey=%project_key%&language=xml"