19 Nisan 2018 Perşembe

VSTS - BITNAMI SONARQUBE INTEGRATION WITH HTTPS ( SSL ) SUPPORT

0) Configure your Sonarqube VM to Support SSL.
You may create your own certificate for testing purposes.

1) VSTS build definition tasks overview


2) Upload Certificate
Secure File : The certificate file that should normally be installed on a client machine that consumes the https sonar service.

3) Install the certificate to the machine store
-enterprise -f -v -AddStore "Root" %DOWNLOADSECUREFILE_SECUREFILEPATH%


This definition resolves the issue below
2018-04-17T08:22:01.9086691Z 08:22:01.907  Failed to request and parse 'https://xxxx.westeurope.cloudapp.azure.com/api/server/version': The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
2018-04-17T08:22:01.9090730Z 08:22:01.908  A server certificate could not be validated. Possible cause: you are using a self-signed SSL certificate but the certificate has not been installed on the client machine. Please make sure that you can access https://xxxx.westeurope.cloudapp.azure.com/ without encountering certificate errors.
2018-04-17T08:22:01.9107214Z 08:22:01.91  Pre-processing failed. Exit code: 1


4) Install the certificate to the java store
-importcert -v -trustcacerts -alias xxxxxsonar -file %DOWNLOADSECUREFILE_SECUREFILEPATH% -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -storepass changeit -noprompt

This definition resolves the issue below
ERROR: SonarQube server [https://xxxx.westeurope.cloudapp.azure.com] can not be reached
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to execute SonarQube
ERROR: Caused by: Fail to get bootstrap index from server
ERROR: Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
ERROR: Caused by: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
ERROR: Caused by: unable to find valid certification path to requested target

5) Configure Sonarqube endpoint



6) Configure Build Definition Sonarqube tasks
No additional settings



7) Configure Environment Variables
This definition resolves the issue below
2018-04-19T08:47:57.5278222Z ##[error][SQ] Could not fetch metrics
2018-04-19T08:47:57.5288112Z ##[error][SQ] API GET '/api/metrics/search' failed, error was: {"code":"DEPTH_ZERO_SELF_SIGNED_CERT"}
2018-04-19T08:47:58.8930802Z ##[error][SQ] API GET '/api/ce/task' failed, error was: {"code":"DEPTH_ZERO_SELF_SIGNED_CERT"}
2018-04-19T08:47:58.8937152Z ##[error][SQ] Could not fetch task for ID 'AWLdFrLHT4lYqxgABePI'
2018-04-19T08:47:58.9046267Z ##[section]Finishing: Publish Quality Gate Result
DEPTH_ZERO_SELF_SIGNED_CERT

And finally, enjoy your build green :)