forked from electric-cloud/DSL-Samples
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathScmSync.groovy
69 lines (61 loc) · 2.13 KB
/
ScmSync.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
CloudBees CD/RO DSL: Create Git and ScmSyn configurations
With v10.3 first class plugin configurations were introduced as were previews
of SCM sync objects. This example shows how to set up these configurations to
enable synchronizing a Git repository with a CloudBees CD/RO server.
Objects Created
- EC-Git plugin configuration
- scmSync configuration
- trigger git polling configuration
Instructions
- Create a git token that can be used to run APIs against your git provider
(GitHub, Bitbucket, etc) and set the GitToken variable below to that value
- Create a git repository with CloudBees CD/RO DSL content. This can be DSL
files at the root of of the repository and or use the "Export DSL" Self-
service catalog items to generated a DSL directory hierarchy. Fill in the
value for the Repo variable below.
- Run this DSL to create the objects
ectool evalDsl --dslFile ScmSync.groovy
- Periodially, you will see a job that runs this EC-Git plugin procedure "Polling".
This procedure will apply any the code from your repository if there are changes.
*/
def GitToken = ''
def Repo = 'https://github.com/cb-thunder/GitOps.git'
project "GitOps",{
pluginConfiguration 'GitHub', {
field = [
'authType': 'token',
'debugLevel': '0',
'ignoreSSLErrors': 'false',
'library': 'jgit',
'repositoryURL': Repo,
'token_credential': 'token_credential',
]
pluginKey = 'EC-Git'
credential 'token_credential', {
userName = ''
password = GitToken
}
}
scmSync "My GitOps",{
branch = "main"
configurationName = "GitHub"
configurationProjectName = projectName
destinationDir = "tmp"
repository = Repo
scmType = "git"
syncType = "fromScm"
resourceName = "local"
trigger "My GitOps trigger",{
triggerType = "polling"
pluginKey = "EC-Git"
}
}
}
// ACL entry required because repository is creating a new project
// Add ACL entries for any other objects being create or modified by the repo DSL
aclEntry systemObjectName: "projects",
objectType: 'systemObject',
principalType : 'user',
principalName: "project: GitOps",
modifyPrivilege : 'allow'