0
votes

We use Sonatype Nexus as artefact repository, configured with credentials in Jenkins and it works fine. Now i'm trying to get get a gradle project running as jenkins multibranch pipeline job using gradlew including a sonarqube code scan.
Problem: when using only the rootProjekt.name property in settings.gradle i get this error:

  • What went wrong: Plugin [id: 'org.sonarqube', version: '2.6.2'] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)

  • Plugin Repositories (could not resolve plugin artifact 'org.sonarqube:org.sonarqube.gradle.plugin:2.6.2') Searched in the following repositories: Gradle Central Plugin Repository

The sonarqube gradle plugin is found when using the Nexus web UI, but not by gradle inside the pipeline, seems it searches only in Gradle Central Plugin Repository. When using a Settings.gradle like that:

pluginManagement {
  repositories {
    maven {
      url "http://nexushost/content/groups/public/"
    }

  }
}

rootProject.name = 'fooBar'

it works like a charm. How to tell gradle it should always use the sonatype nexus host without having to configure it in settings.gradle for every Job ?

1

1 Answers

0
votes

You should use a Gradle init script.

For example, in every agent, create a file USER_HOME/.gradle/init.d/use-corporate-nexus.gradle, with content:

settingsEvaluated { settings ->
    settings.pluginManagement {
        repositories {
            maven {
                url "http://nexushost/content/groups/public/"
            }
        }
    }
}