How to invoke method from sonarqube properties closure?

I am using sonar-scanner-gradle 2.6.2 with the following configuration closure:

sonarqube {
  properties {
      property "sonar.host.url", "https://example.com/sonar"
      property "sonar.analysis.mode", "preview"
      property "sonar.gitlab.commit_sha", commitHash
  }
}

I would like to structure the closure block a bit by encapsulating a few lines into a separate method:

sonarqube {
  properties {
      property "sonar.host.url", "https://example.com/sonar"
      configureGitLab(this)
  }
}

private def configureGitLab(project) {
  project.property "sonar.analysis.mode", "preview"
  project.property "sonar.gitlab.commit_sha", commitHash
}

When I let Gradle run the “sonarqube” task the following error occurs:

Could not find method property() for arguments [sonar.analysis.mode, preview] on project ‘:example’ of type org.gradle.api.Project.

How can I structure my configuration code?

I found the following notation to use a separate method:

sonarqube {
  properties {
      property "sonar.host.url", "https://example.com/sonar"
      configureGitLab(properties)
  }
}


def configureGitLab(HashMap properties) {
    properties.put "sonar.analysis.mode", "preview"
    properties.put "sonar.gitlab.commit_sha", commitHash
}