# Azure DevOps CLI scanner JRE provisioning

**URL:** <https://community.sonarsource.com/t/azure-devops-cli-scanner-jre-provisioning/129565>\
**Category:** SonarQube Cloud\
**Tags:** azuredevops, scanner\
**Created:** [October 31, 2024, 3:18am UTC](https://community.sonarsource.com/t/azure-devops-cli-scanner-jre-provisioning/129565 "2024-10-31T03:18:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfebl](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cfebl](https://community.sonarsource.com/u/cfebl)\
**Post date:** [October 31, 2024, 3:18am UTC](https://community.sonarsource.com/t/azure-devops-cli-scanner-jre-provisioning/129565/1 "2024-10-31T03:18:46Z")

</div>

Hello,

We’re using the Azure DevOps pipelines plugin for SonarCloud with self-hosted runners that do not have a JRE.

For .NET projects, we’ve been using the JRE provisioning capability of the 7+ .NET scanner (by specifying `msBuildVersion` to 7+ when the AZDO plugin was at version 2, and now by leaving the defaults since version 3 following the [recent announcement](https://community.sonarsource.com/t/sonarqube-and-sonarcloud-extensions-for-azure-devops-v3-0-1-v7-0-1/128606)).

Example task for .NET:

```yaml
- task: SonarCloudPrepare@3
  inputs:
    SonarCloud: '...'
    organization: '...'
    scannerMode: 'dotnet'
    projectKey: '...'
    projectName: '...'

```

For JavaScript projects, we want to use the same JRE provisioning capability of the 6+ CLI scanner, but we’re encountering an issue. Given the following definition:

```yaml
- task: SonarCloudPrepare@3
  inputs:
    SonarCloud: '...'
    organization: '...'
    scannerMode: 'cli'
    configMode: 'file'

```

We have a JRE provisioning error:

```auto
ERROR: JAVA_HOME not found in your environment, and no Java
       executable present in the PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation, or add "java.exe" to the PATH

```

We’ve tracked the problem down to the runner downloading the “Any” platform variant of the CLI scanner, which does not support JRE provisioning, and as a workaround we’re abusing the `cliScannerVersion` property to force the download of the platform-specific variant:

```yaml
- task: SonarCloudPrepare@3
  inputs:
    SonarCloud: '...'
    organization: '...'
    scannerMode: 'cli'
    cliScannerVersion: '6.2.1.4610-windows-x64'
    configMode: 'file'

```

This workaround resolves the issue, but this feels “hacky” and we now have to regularly update the pipeline definition to follow new releases.

Maybe having a separate property available in the AZDO plugin to specify the platform while keeping the default version would be good enough for us and doesn’t seem like a breaking change.

A few examples of how it might work:

```yaml
- task: SonarCloudPrepare@3
  inputs:
    scannerMode: 'cli'
    # ...
# => Downloads "sonar-scanner-cli-[default version].zip"

- task: SonarCloudPrepare@3
  inputs:
    scannerMode: 'cli'
    cliScannerVersion: '6.2.1.4610'
    # ...
# => Downloads "sonar-scanner-cli-6.2.1.4610.zip"

- task: SonarCloudPrepare@3
  inputs:
    scannerMode: 'cli'
    cliScannerPlatform: 'windows-x64'
    # ...
# => Downloads "sonar-scanner-cli-[default version]-windows-x64.zip"

- task: SonarCloudPrepare@3
  inputs:
    scannerMode: 'cli'
    cliScannerVersion: '6.2.1.4610'
    cliScannerPlatform: 'windows-x64'
    # ...
# => Downloads "sonar-scanner-cli-6.2.1.4610-windows-x64.zip"

```

---

<div class="post-metadata">

**Author:** ![Julien\_HENRY](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/julien_henry/32/61_2.png) [@Julien\_HENRY](https://community.sonarsource.com/u/Julien_HENRY)\
**Post date:** [November 21, 2024, 9:26am UTC](https://community.sonarsource.com/t/azure-devops-cli-scanner-jre-provisioning/129565/4 "2024-11-21T09:26:46Z")

</div>

Hi @cfebl

Thanks for your suggestion, this is a fair point.

I have created a ticket in the backlog: [Jira](https://sonarsource.atlassian.net/browse/SONARAZDO-443)

---

<div class="post-metadata">

**Author:** ![cfebl](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cfebl](https://community.sonarsource.com/u/cfebl)\
**Post date:** [November 21, 2024, 2:29pm UTC](https://community.sonarsource.com/t/azure-devops-cli-scanner-jre-provisioning/129565/6 "2024-11-21T14:29:15Z")

</div>

Hello, thanks, that’s great news!
