"Could not fetch metrics" error while publishing quality gate result

We receive this error below on Azure Devops pipelines on hosted build agent.

##[error][SQ] Could not fetch metrics

##[error][SQ] API GET ‘/api/metrics/search’ failed, error was: {“code”:“UNABLE_TO_GET_ISSUER_CERT_LOCALLY”}

##[error][SQ] API GET ‘/api/server/version’ failed, error was: {“code”:“UNABLE_TO_GET_ISSUER_CERT_LOCALLY”}

Hey there.

When custom certificates (self-signed, for example) are used, this means it requires passing certificates to the Node process. This is similar to importing certificates into a Java keystore if you’re familiar.
Ultimately – you will need to pass a .pem file containing your certificates to the
NODE_EXTRA_CA_CERTS environment variable. Please read the link just shared to better understand how to use this environment variable to set your custom certificate.

How those certificates reach the build agent is up to you – and the NODE_EXTRA_CA_CERTS environment variable can be set in the Variables tab of an Azure DevOps Pipeline (those variables act as environment variables).