SonarSource/sonarqube · error · GradleException

Invalid artifactoryUrl

Error message

Invalid artifactoryUrl

What it means

When Artifactory credentials are present (ARTIFACTORY_ACCESS_TOKEN env var or artifactoryPassword property), the build also requires a non-empty Artifactory URL (ARTIFACTORY_URL env var or artifactoryUrl property). If the password/token is set but the URL is empty, the build throws GradleException('Invalid artifactoryUrl') before configuring the authenticated Maven repository.

Source

Thrown at build.gradle:114

    tasks.matching { it.name.matches(bomTasks) }.all({
      logger.info("{} disabled", it.name);
      it.enabled = false
    })
  }

  repositories {
    // For local development: resolve artifacts from local Maven repository
    mavenLocal()

    // The environment variables ARTIFACTORY_USERNAME and ARTIFACTORY_ACCESS_TOKEN are used on QA env (Jenkins)
    // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
    def artifactoryUsername = System.env.'ARTIFACTORY_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
    def artifactoryPassword = System.env.'ARTIFACTORY_ACCESS_TOKEN' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
    def artifactoryUrl = System.getenv('ARTIFACTORY_URL') ?: (project.hasProperty('artifactoryUrl') ? project.getProperty('artifactoryUrl') : '')

    if (artifactoryPassword) {
      if (artifactoryUrl == '') {
        throw new GradleException('Invalid artifactoryUrl')
      }
      maven {
        authentication {
          header(HttpHeaderAuthentication)
        }
        credentials(HttpHeaderCredentials) {
          name = "Authorization"
          value = "Bearer $artifactoryPassword"
        }
        url "${artifactoryUrl}/sonarsource"
      }
      maven {
        authentication {
          header(HttpHeaderAuthentication)
        }
        credentials(HttpHeaderCredentials) {
          name = "Authorization"
          value = "Bearer $artifactoryPassword"

View on GitHub (pinned to 184c821202)

Solutions

  1. Set ARTIFACTORY_URL (or gradle property artifactoryUrl) to your Artifactory base URL
  2. Or remove ARTIFACTORY_ACCESS_TOKEN/artifactoryPassword if Artifactory is not needed
  3. Verify in CI that both ARTIFACTORY_URL and ARTIFACTORY_ACCESS_TOKEN secrets are defined

Example fix

// before
export ARTIFACTORY_ACCESS_TOKEN=token   # no URL
// after
export ARTIFACTORY_ACCESS_TOKEN=token
export ARTIFACTORY_URL=https://artifactory.example.com/artifactory
Defensive patterns

Strategy: validation

Validate before calling

// shell: both credentials and URL must be set together
if [ -n "$ARTIFACTORY_ACCESS_TOKEN" ] && [ -z "$ARTIFACTORY_URL" ]; then
  echo "ARTIFACTORY_URL is required when ARTIFACTORY_ACCESS_TOKEN is set" >&2
  exit 1
fi

Prevention

When it happens

Trigger: Setting ARTIFACTORY_ACCESS_TOKEN (or gradle property artifactoryPassword) but leaving ARTIFACTORY_URL unset/empty and no artifactoryUrl gradle property defined; e.g. credentials configured in CI secrets but URL secret missing.

Common situations: Partial Artifactory configuration where only credentials were provisioned; typo'd env var name for the URL; properties file with artifactoryPassword but no artifactoryUrl key.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/5f8c1b74ad6c96d0. Report an issue: GitHub.