简体   繁体   中英

Plugin [id: 'org.sonarqube', version: '2.6.2'] was not found

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 ?

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/"
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM