V6 of SonarQube AzureDevops tasks are not working

I received a notification that V5 tasks were deprecated but when changing it to use V6 I get

/home/vsts/work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/6.0.0/SonarQubePrepare.js:22
`,d.message,d.stack);var c=new Error(“tunneling socket could not be established, cause=”+d.message);c.code=“ECONNRESET”,t.request.emit(“error”,c),r.removeSocket(s)}};xi.prototype.removeSocket=function(t){var i=this.sockets.indexOf(t);if(i!==-1){this.sockets.splice(i,1);var r=this.requests.shift();r&&this.createSocket(r,function(s){r.request.onSocket(s)})}};function vm(e,t){var i=this;xi.prototype.createSocket.call(i,e,function(r){var s=e.request.getHeader(“host”),o=mu({},i.options,{socket:r,servername:s?s.replace(/:.*$/,“”):e.host}),n=Qg.connect(0,o);i.sockets[i.sockets.indexOf(r)]=n,t(n)})}function ym(e,t,i){return typeof e==“string”?{host:e,port:t,localAddress:i}:e}function mu(e){for(var t=1,i=arguments.length;t<i;++t){var r=arguments[t];if(typeof r==“object”)for(var s=Object.keys(r),o=0,n=s.length;o<n;++o){var l=s[o];r[l]!==void 0&&(e[l]=r[l])}}return e}var dr;process.env.NODE_DEBUG&&/\btunnel\b/.tes

Do you have access to the internet on your build server? It seems to be required for V6 tasks, see also Azure Pipeline Task SonarQubePrepare@6 looking for online resources

This is on AzureDevOps itself not a self hosted environment and it is using Microsoft agents.

Hi,

Can you provide the full, debug log, please?

Here’s how to get that:
* “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
* For example:
yml - task: SonarCloudPrepare@1 inputs: SonarCloud: 'sonarcloud' organization: 'foo' scannerMode: 'MSBuild' projectKey: 'foo_sonar-scanning-someconsoleapp' projectName: 'sonar-scanning-someconsoleapp' extraProperties: | sonar.verbose=true

  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)
     
    Thx,
    Ann

I am glad I am not the only getting this error and it seems there quite a few others seeing this also. How long will the v5 tasks be supported before the deprecation is permanent? I tried adding the verbose log, but where do we get that log, as the task output is identical.

1 Like

Hi @Devin_Quince,

Can you provide a full, debug log?

 
Ann

As I said in my response, I set the sonar.verbose=true property, but am not sure where to get the debug log from, as my pipeline log is the same. Can you point me in the right direction?
sonarqubelogs.zip (149.8 KB)
I have attached my SQL logs after enabling debug at the server level and then running my pipeline. Not sure if this is what you are after.

1 Like

Hi,

I’m looking for a debug analysis log.

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

My prepare@6 task just as this, so I am not sure we are even getting that far. As for the link, I am still not sure where to look for the analysis debug log after reviewing those

2024-06-14T13:14:28.4533822Z ##[section]Starting: SonarQubePrepare
2024-06-14T13:14:28.4645044Z ==============================================================================
2024-06-14T13:14:28.4645217Z Task         : Prepare Analysis Configuration
2024-06-14T13:14:28.4645325Z Description  : Prepare SonarQube analysis configuration
2024-06-14T13:14:28.4645446Z Version      : 6.0.0
2024-06-14T13:14:28.4645515Z Author       : sonarsource
2024-06-14T13:14:28.4646021Z Help         : [More Information](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops/)
2024-06-14T13:14:28.4646223Z ==============================================================================
2024-06-14T13:14:28.4775325Z ##[debug]Resource Utilization warnings is disabled, switch "DISABLE_RESOURCE_UTILIZATION_WARNINGS" variable to "true" if you want to enable it
2024-06-14T13:14:28.4815450Z ##[debug]Using node path: G:\bld01resware1\externals\node10\bin\node.exe
2024-06-14T13:14:28.5311119Z ##[debug]Agent environment resources - Disk: G:\ Available 639305.00 MB out of 1023981.00 MB, Memory: Used 22539.00 MB out of 49150.00 MB, CPU: Usage 1.50%
2024-06-14T13:14:29.3437813Z G:\bld01resware1\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\6.0.0\SonarQubePrepare.js:22
2024-06-14T13:14:29.3454524Z `,d.message,d.stack);var c=new Error("tunneling socket could not be established, cause="+d.message);c.code="ECONNRESET",t.request.emit("error",c),r.removeSocket(s)}};xi.prototype.removeSocket=function(t){var i=this.sockets.indexOf(t);if(i!==-1){this.sockets.splice(i,1);var r=this.requests.shift();r&&this.createSocket(r,function(s){r.request.onSocket(s)})}};function vm(e,t){var i=this;xi.prototype.createSocket.call(i,e,function(r){var s=e.request.getHeader("host"),o=mu({},i.options,{socket:r,servername:s?s.replace(/:.*$/,""):e.host}),n=Qg.connect(0,o);i.sockets[i.sockets.indexOf(r)]=n,t(n)})}function ym(e,t,i){return typeof e=="string"?{host:e,port:t,localAddress:i}:e}function mu(e){for(var t=1,i=arguments.length;t<i;++t){var r=arguments[t];if(typeof r=="object")for(var s=Object.keys(r),o=0,n=s.length;o<n;++o){var l=s[o];r[l]!==void 0&&(e[l]=r[l])}}return e}var dr;process.env.NODE_DEBUG&&/\btunnel
2024-06-14T13:14:29.3457178Z 
2024-06-14T13:14:29.3457386Z SyntaxError: Unexpected token ?
2024-06-14T13:14:29.3457715Z     at Module._compile (***/modules/cjs/loader.js:723:23)
2024-06-14T13:14:29.3458018Z     at Object.Module._extensions..js (***/modules/cjs/loader.js:789:10)
2024-06-14T13:14:29.3458441Z     at Module.load (***/modules/cjs/loader.js:653:32)
2024-06-14T13:14:29.3460106Z     at tryModuleLoad (***/modules/cjs/loader.js:593:12)
2024-06-14T13:14:29.3461219Z     at Function.Module._load (***/modules/cjs/loader.js:585:3)
2024-06-14T13:14:29.3462680Z     at Function.Module.runMain (***/modules/cjs/loader.js:831:12)
2024-06-14T13:14:29.3463668Z     at startup (***/bootstrap/node.js:283:19)
2024-06-14T13:14:29.3464783Z     at bootstrapNodeJSCore (***/bootstrap/node.js:623:3)
2024-06-14T13:14:30.1694835Z ##[error]Exit code 1 returned from process: file name 'G:\bld01resware1\externals\node10\bin\node.exe', arguments '"G:\bld01resware1\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\6.0.0\SonarQubePrepare.js"'.
2024-06-14T13:14:30.1700455Z ##[debug]Microsoft.VisualStudio.Services.Agent.Util.ProcessExitCodeException: Exit code 1 returned from process: file name 'G:\bld01resware1\externals\node10\bin\node.exe', arguments '"G:\bld01resware1\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\6.0.0\SonarQubePrepare.js"'.
   at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Agent.Sdk\ProcessInvoker.cs:line 389
   at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Microsoft.VisualStudio.Services.Agent\ProcessInvoker.cs:line 329
   at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, Boolean continueAfterCancelProcessTreeKillAttempt, TimeSpan sigintTimeout, TimeSpan sigtermTimeout, Boolean useGracefulShutdown, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Agent.Worker\Handlers\StepHost.cs:line 85
   at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.NodeHandler.RunAsync() in D:\a\_work\1\s\src\Agent.Worker\Handlers\NodeHandler.cs:line 251
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsyncInternal() in D:\a\_work\1\s\src\Agent.Worker\TaskRunner.cs:line 459
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() in D:\a\_work\1\s\src\Agent.Worker\TaskRunner.cs:line 76
   at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in D:\a\_work\1\s\src\Agent.Worker\StepsRunner.cs:line 264
2024-06-14T13:14:30.1702861Z ##[section]Finishing: SonarQubePrepare
1 Like

Hi,

Thanks.

I’ve flagged this for more expert eyes.

 
Ann

Hey there.

2024-06-14T13:14:30.1694835Z ##[error]Exit code 1 returned from process: file name ‘G:\bld01resware1\externals\node10\bin\node.exe’, arguments ‘“G:\bld01resware1_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\6.0.0\SonarQubePrepare.js”’.

This is super strange for me, as these tasks should be using the Node 16 runner.

But the logs are indicating Node 10 is being used.

Can you make sure your agent doesn’t have the AGENT_USE_NODE10 environment variable set to true?

1 Like

Thanks, it looks we were using that, so after setting it to false, prepare works, but now analyze is failing with this error

##[error]Error: LinkageError occurred while loading main class org.sonarsource.scanner.cli.Main
##[debug]Processed: ##vso[task.logissue type=error;]Error: LinkageError occurred while loading main class org.sonarsource.scanner.cli.Main
Error: LinkageError occurred while loading main class org.sonarsource.scanner.cli.Main
##[error]java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
##[debug]Processed: ##vso[task.logissue type=error;]java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
	java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Process returned exit code 1
##[error]The SonarScanner did not complete successfully
##[debug]Processed: ##vso[task.logissue type=error;]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]07:19:53.388  Post-processing failed. Exit code: 1
##[debug]Processed: ##vso[task.logissue type=error;]07:19:53.388  Post-processing failed. Exit code: 1
07:19:53.388  Post-processing failed. Exit code: 1
##[debug]Exit code 1 received from tool 'G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe'
##[debug]STDIO streams have closed for tool 'G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe'
##[warning]Can't find loc string for key: LIB_ProcessExitCode
##[debug]Processed: ##vso[task.issue type=warning;]Can't find loc string for key: LIB_ProcessExitCode
##[warning]Error while executing SonarQube:Analyze task: LIB_ProcessExitCode G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe 1
##[debug]Processed: ##vso[task.issue type=warning;]Error while executing SonarQube:Analyze task: LIB_ProcessExitCode G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe 1
##[debug]task result: Failed
##[error]LIB_ProcessExitCode G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe 1
##[debug]Processed: ##vso[task.issue type=error;]LIB_ProcessExitCode G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe 1
##[debug]Processed: ##vso[task.complete result=Failed;]LIB_ProcessExitCode G:\bld01resware1\_work\_temp\b2f448d5-db35-4f8d-bf7c-5c71b428ad37\SonarScanner.MSBuild.exe 1
Finishing: SonarQubeAnalyze

Well, we’re closer!

It sounds like JAVA_HOME on your agent points to a Java 8 install. Assuming Java 17 is available on your instance and pointed to via the JAVA_HOME_17_X64 environment variable, you can adjust your task like this to point to the right version:

- task: SonarQubeAnalyze@6
  inputs:
    jdkversion: 'JAVA_HOME_17_X64'

(Azure Devops Extension Docs | Scanner Environment docs)

I upgraded JDK Development Kit 22.0.1 per our IT dept and set the following in my pipeline, which points to the install of C:\Program Files\Java\jdk-22 and all appears to be working now.

- task: SonarQubeAnalyze@6
  inputs:
    jdkversion: 'JAVA_HOME_22_X64'
2 Likes

Thanks. It didn’t actually occur to me that any environment variable could be placed there, not just the ones we documented!

Hi, I’m facing a similar problem.
I’m using a self-hosted agent ubuntu 20.04 version 3.241.0, with node16 and SonarQube v9.9.5.
In my case there is no AGENT_USE_NODE10 environment variable defined, and even that the error persist.

Azure devops pipeline SonarQubePrepare@6 task:

Starting: Prepare SonarQube
==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarQube analysis configuration
Version      : 6.2.0
Author       : sonarsource
Help         : [More Information](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops/)
==============================================================================
/agent/_work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/6.2.0/SonarQubePrepare.js:22
`,finalEOL:i=!0,replacer:r=null,spaces:s}={}){let o=i?t:"";return JSON.stringify(e,r,s).replace(/\n/g,t)+o}function Qg(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}am.exports={stringify:Jg,stripBom:Qg}});var dm=B((Qj,um)=>{var Pn;try{Pn=Yt()}catch{Pn=require("fs")}var Ra=Xt(),{stringify:lm,stripBom:pm}=Va();async function Kg(e,t={}){typeof t=="string"&&(t={encoding:t});let i=t.fs||Pn,r="throws"in t?t.throws:!0,s=await Ra.fromCallback(i.readFile)(e,t);s=pm(s);let o;try{o=JSON.parse(s,t?t.reviver:null)}catch(n){if(r)throw n.message=`${e}: ${n.message}`,n;return null}return o}var Xg=Ra.fromPromise(Kg);function Yg(e,t={}){typeof t=="string"&&(t={encoding:t});let i=t.fs||Pn,r="throws"in t?t.throws:!0;try{let s=i.readFileSync(e,t);return s=pm(s),JSON.parse(s,t.reviver)}catch(s){if(r)throw s.message=`${e}: ${s.message}`,s;return null}}async function Zg(e,t,i={}){let r=i.fs||Pn,s=lm

SyntaxError: Unexpected token ?
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
##[error]Exit code 1 returned from process: file name '/agent/externals/node10/bin/node', arguments '"/agent/_work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/6.2.0/SonarQubePrepare.js"'.
Finishing: Prepare SonarQube

Where did you set AGENT_USE_NODE10=false? In your Azure Pipelines YML?

Colin,
Sorry, I meant that this variable is noT configured

Can you try setting it to false?

Hi Colin,
This is the point, there is no AGENT_USE_NODE10 environment variable being used in my environment.

As an attempt, I added the UseNode@ using node16 in my yaml, but still when running the SonarQubePrepare@6 task I get the same error