Azure DevOps: build artifact download error "Error: in getBuildApi, so retrying => retries pending : 4"

I got this error when using the task 'Download Build Artifact' in the release pipeline of devops server 2019 or devops server 2020:

Error: in getBuildApi, so retrying => retries pending : 4

Detailed errors can be found when using diagnostic logging and / or by adding log statements to main.js in the agent\_work\_tasks\DownloadBuildArtifacts_a433f589-fce1-4460-9ee6-44a624aeb1fb directory:

Failed in getBuildApi with error: Error: unable to get local issuer certificate and

    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket._finishInit (_tls_wrap.js:609:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:439:38) code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'``` 

The problem was an certificate we used on our devops server which is not trusted by node. I think it has something to do with the root certificate because browsing to our devops server with chrome give no problems on the build agent. (The certificate is valid.)

To solve this issue set the following environment system variable and restart the agent services NODE_TLS_REJECT_UNAUTHORIZED=0


This is an old question, but the other option would be to download the certificate chain onto the machine and set the environment variable NODE_EXTRA_CA_CERTS to "/path/to/cert/file".