forked from AnalogJ/you-dont-know-jenkins-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3003.plugin-pipeline-library.groovy
31 lines (27 loc) · 1.15 KB
/
3003.plugin-pipeline-library.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import jenkins.model.Jenkins;
import jenkins.model.*;
import hudson.tasks.*;
import jenkins.model.*;
import org.jenkinsci.plugins.workflow.libs.*;
import jenkins.plugins.git.*;
println "///////////////////////////////////////////////////////////////////////////"
println "Init Hook: Global Pipeline Library plugin"
println "///////////////////////////////////////////////////////////////////////////"
def pipeline_library_remote = "git@github.com:owner/repo.git"
def pipeline_library_name = "repo"
def ssh_key_credential_id = "123-456"
def globalPipelineLibraries = GlobalLibraries.get()
//setup Git SCM
def scmSharedLibrary = new SCMSourceRetriever(new GitSCMSource(
null, //SCM id, automatically created.
pipeline_library_remote, //remote
ssh_key_credential_id, //credentialsId
'*', //includes
'', //excludes
true //ignoreOnPushNotifications
))
def esLibraryConfiguration = new LibraryConfiguration(pipeline_library_name, scmSharedLibrary)
esLibraryConfiguration.setDefaultVersion('master')
esLibraryConfiguration.setImplicit(true)
globalPipelineLibraries.setLibraries([esLibraryConfiguration])
globalPipelineLibraries.save()