Update GitHub Actions dependencies (major) (#271)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Sebastian Zumbrunn sebastian.zumbrunn@sonarsource.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
Scan your code with SonarQube

A GitHub Action for SonarQube
This GitHub Action integrates continuous code quality and security analysis directly into your workflow. It scans your project with either SonarQube Server or SonarQube Cloud, helping you catch bugs, security vulnerabilities, and code smells automatically within your CI/CD pipeline. This action is the official method for scanning C, C++, Objective-C, and Dart projects via GitHub Actions.
What is SonarQube?
SonarQube Server and SonarQube Cloud are widely used static analysis solutions for continuous code quality, security inspection, and fix remediation. The platform supports over in 30+ languages, frameworks, and IaC platforms, including Java, JavaScript, TypeScript, C#, Python, C, C++, and many more.
Quick Start
1. Prerequisites:
You must have a project already set up on SonarQube Cloud or SonarQube Server. This action performs the analysis, but the project must exist on the platform to receive the results.
For more information, see Key Requirements.
2. Required variables:
The action needs two key variables to connect to the SonarQube instance and run the analysis. These should be stored as GitHub secrets or variables for security.
•
SONAR_TOKEN: The authentication token required to access the SonarQube instance. This is a mandatory secret for all use cases.•
SONAR_HOST_URL: The URL of the SonarQube Server. This is required for self-hosted SonarQube Server but not needed for SonarQube Cloud.For more information, see Configuration.
3. Quick Start Workflow Example (for SonarQube Cloud)
Create or update your CI pipeline to run the scan action:
Create a configuration file in the root directory of the project and name it
sonar-project.properties:For other workflows, see Workflow Examples.
Important: Special Cases and alternatives
This GitHub Action will not work for all technologies. If you are in one of the following situations, you should use the following alternatives:
Do not use this GitHub action if:
If you want to use Software Composition Analysis (SCA)
Dependency scanning with SonarQube Advanced Security SCA may not work correctly if scanning requires on-the-fly manifest file generation. See the SCA analysis environment requirement documentation for Cloud or Server.
Key requirements
To use this GitHub Action you need to meet the following prerequisites for your choosen SonarQube platform.
For SonarQube Cloud
For SonarQube Server
Read more information on how to analyze your code here.
Configuration
Action parameters
projectBaseDirYou can change the analysis base directory by using the optional input
projectBaseDirlike this:scannerVersionIn case you need to specify the version of the Sonar Scanner, you can use the
scannerVersionoption:argsIn case you need to add additional analysis parameters, and you do not wish to set them in the
sonar-project.propertiesfile, you can use theargsoption:scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. quotes```
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. “
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. quotes```
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. quotes```
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. “
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. ‘,
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. quotes```
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. “
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. quotes```
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. “
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. ‘,
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. “
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. quotes```
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials. ‘,
scannerBinariesUrlYou can also specify the URL where to retrieve the SonarScanner CLI from. The specified URL overrides the default address:
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli. This can be useful when the runner executing the action is self-hosted and has regulated or no access to the Internet:scannerBinariesAuthHeaderIf the server specified by
scannerBinariesUrlrequires authentication, you can provide anAuthorizationheader value using thescannerBinariesAuthHeaderoption. The value is passed directly as theAuthorizationHTTP header, so you must include the scheme (e.g.Bearer,Basic):Store the full header value (e.g.
Bearer mytoken) in the GitHub secret to avoid exposing credentials.skipSignatureVerificationBy default, the action verifies the OpenPGP signature of the SonarScanner CLI binary before executing it. You can disable this verification using the
skipSignatureVerificationoption:More information about possible analysis parameters can be found:
Environment variables
SONAR_TOKEN– Required this is the token used to authenticate access to SonarQube. You can read more about security tokens in the documentation of SonarQube Server and Cloud. You can set theSONAR_TOKENenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).SONAR_HOST_URL– this tells the scanner where SonarQube Server is hosted. You can set theSONAR_HOST_URLenvironment variable in the “Variables” settings page of your repository, or you can add them at the level of your GitHub organization (recommended). Not needed for SonarQube Cloud.SONAR_ROOT_CERT– Holds an additional certificate (in PEM format) that is used to validate the certificate of SonarQube Server or of a secured proxy to SonarQube (Server or Cloud). You can set theSONAR_ROOT_CERTenvironment variable in the “Secrets” settings page of your repository, or you can add them at the level of your GitHub organization (recommended).Here is an example of how you can pass a certificate (in PEM format) to the Scanner truststore:
If your source code file names contain special characters that are not covered by the locale range of
en_US.UTF-8, you can configure your desired locale like this:Workflow Examples
For SonarQube Cloud
Project metadata, including the location of the sources to be analyzed, must be declared in the file sonar-project.properties in the base directory:
Standard Projects
For projects that:
the workflow, usually declared under
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
See also example configurations of C++ projects for SonarQube Cloud.
For SonarQube Server
Project metadata, including the location of the sources to be analyzed, can be declared in the file
sonar-project.propertiesin the base directory:Standard Projects
For projects that:
.github/workflows/build.yml, looks like the following:C/C++/Objective-C with Build Wrapper
This subsection would contain the more complex YAML configuration for projects that require the build wrapper to generate a compilation database. The example would detail the three-step process: checking out the code, installing the build wrapper, and then running the SonarQube scan with the appropriate parameters.
For C, C++, and Objective-C projects relying on Build Wrapper to generate the compilation database, the workflow requires additional steps to download the Build Wrapper and invoke it:
If you are using SonarQube Server 10.5 or earlier, use
sonar.cfamily.build-wrapper-outputinstead ofsonar.cfamily.compile-commandsin theargsproperty of the last step, as Build Wrapper does not generate acompile_commands.jsonfile before SonarQube Server 10.6.It should look like this:
See also example configurations of C++ projects for SonarQube Server.
Advanced Settings
Self-hosted runner or container
When running the action in a self-hosted runner or container, please ensure that the following programs are installed:
Note:
gpganddirmngrare only required for GPG signature verification (enabled by default). They can be omitted when settingskipSignatureVerification: true.Additional information
The
sonarqube-scan-action/install-build-wrapperaction installscoreutilsif run on macOS.Support & Community
To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum page for SonarQube Server or SonarQube Cloud.
License
Container images built with this project include third-party materials.