mkobit / jenkins-pipeline-shared-libraries-gradle-plugin

Gradle plugin to help with build and test of Jenkins Pipeline Shared Libraries (see https://jenkins.io/doc/book/pipeline/shared-libraries/)
MIT License
148 stars 29 forks source link

Retrieve jenkins core and jenkins plugins from a custom url #101

Closed blbeatty closed 4 years ago

blbeatty commented 4 years ago

When using this plugin, I'm trying to download the jenkins core and plugin dependencies through a custom repo rather than the default https://repo.jenkins-ci.org/public/. Is there a way to change the base url from which these artifacts get retrieved? I am new to gradle and haven't been able to find a way to accomplish this.

cwholmes commented 4 years ago

I also have not been able to achieve this. Any help would be greatly appreciated. But it seems that a code change may be required to achieve this result.

cwholmes commented 4 years ago

One slight hack that I did find was this task being added to the build script

// The plugin we use hard codes the public jenkins repository url.
// This overrides that url.
task replaceJenkinsPublicUrl {
  project.repositories.each { repo ->
    if ('JenkinsPublic'.equals(repo.name)) {
      repo.setUrl('https://myrepo/')
    }
  }
}
blbeatty commented 4 years ago

That works for me. Thanks for sharing your solution

mkobit commented 4 years ago

This was an early decision to make it easier for new consumers to onboard.

Since repositories is mutable, you should be able to remove the existing JenkinsPublic repository and add your own to the repositories {} block.

repositories.removeIf { it.name == "JenkinsPublic" }
blbeatty commented 4 years ago

Gotcha, thanks!