vanderby / SonarQube-AzureAppService

Instructions and files to host SonarQube on an Azure App Service without a container.
MIT License
90 stars 165 forks source link

Won't upgrade past 9.x #85

Closed eeisenbr closed 1 year ago

eeisenbr commented 1 year ago

There's a couple issues that will prevent this from working with SonarQube 10.x (and anything after). First, the sorting of the releases retrieved from GitHub is using alpha, so 9 will always be higher than 10:

    if(!$Version -or ($Version -ieq 'Latest')) {
        # binaries.sonarsource.com moved to S3 and is not easily searchable anymore. Getting the latest version from GitHub releases.
        $releasesFromApi = (Invoke-WebRequest -Uri 'https://api.github.com/repos/SonarSource/sonarqube/releases' -UseBasicParsing).Content
        $releasesPS = $releasesFromApi | ConvertFrom-Json
        $Version = $releasesPS.Name | Sort-Object -Descending | Select-Object -First 1
        Write-Output "Found the latest release to be $Version"
    }

The code above will always find 9.x as the latest release.

Second, the version comparison in the startup script is alpha, having the same problem of 10 being less than 9:

$sqver = $propFile.FullName.split("\")[4].split("-")[1]
log("SQ version: $sqver")
if ($sqver -ge 9.6) {
    log("SQ ver >= 9.6, use env var not wrapper.conf")
    $Env:SONAR_JAVA_PATH = "$Env:JAVA_HOME\bin\java.exe"
    log("Set Java exe path env var (SONAR_JAVA_PATH) to: $Env:SONAR_JAVA_PATH")
} else {
    log('SQ ver < 9.6, use wrapper.conf')

$sqver is a string so "10.1" will always be less than "9.6".

jeckyl2010 commented 1 year ago

There's a couple issues that will prevent this from working with SonarQube 10.x (and anything after). First, the sorting of the releases retrieved from GitHub is using alpha, so 9 will always be higher than 10:

    if(!$Version -or ($Version -ieq 'Latest')) {
        # binaries.sonarsource.com moved to S3 and is not easily searchable anymore. Getting the latest version from GitHub releases.
        $releasesFromApi = (Invoke-WebRequest -Uri 'https://api.github.com/repos/SonarSource/sonarqube/releases' -UseBasicParsing).Content
        $releasesPS = $releasesFromApi | ConvertFrom-Json
        $Version = $releasesPS.Name | Sort-Object -Descending | Select-Object -First 1
        Write-Output "Found the latest release to be $Version"
    }

The code above will always find 9.x as the latest release.

Second, the version comparison in the startup script is alpha, having the same problem of 10 being less than 9:

$sqver = $propFile.FullName.split("\")[4].split("-")[1]
log("SQ version: $sqver")
if ($sqver -ge 9.6) {
    log("SQ ver >= 9.6, use env var not wrapper.conf")
    $Env:SONAR_JAVA_PATH = "$Env:JAVA_HOME\bin\java.exe"
    log("Set Java exe path env var (SONAR_JAVA_PATH) to: $Env:SONAR_JAVA_PATH")
} else {
    log('SQ ver < 9.6, use wrapper.conf')

$sqver is a string so "10.1" will always be less than "9.6".

I'm facing the exact same problem, due to the inherit problem of sorting or comparing numerical values as strings.

Are pull requests something to consider ?

ghost commented 1 year ago

Facing the exact same issue. It does not pull the Latest 10.2 and I can't define version 10.2 as well when deploying. When deploying add version manually from the https://api.github.com/repos/SonarSource/sonarqube/releases and it works.

image

But, then again it shows

image

vanderby commented 1 year ago

@jeckyl2010 I am always open to PR submissions.

As I don't use SQ on a daily basis anymore changes are pretty much community driven at this point.

caosborn commented 1 year ago

I've submitted a PR for this #86

vanderby commented 1 year ago

@caosborn thanks a bunch!

caosborn commented 1 year ago

No worries, hope it helps 🙂