-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup-gocd.sh
executable file
·103 lines (99 loc) · 2.36 KB
/
setup-gocd.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
URL="http://gocd.gunsmoke.local:31468"
# https://api.gocd.org/current/#create-a-config-repo
ConfigRepo() {
curl $URL'/go/api/admin/config_repos' \
-H 'Accept:application/vnd.go.cd.v4+json' \
-H 'Content-Type:application/json' \
-X POST -d '{
"id": "synthetic",
"plugin_id": "yaml.config.plugin",
"material": {
"type": "git",
"attributes": {
"url": "http://gitea-http.gitea.svc.cluster.local:3000/gitea-admin/SyntheticInfra.git",
"branch": "main",
"auto_update": true
}
},
"configuration": [
{
"key": "pattern",
"value": "*.myextension"
}
],
"rules": [
{
"directive": "allow",
"action": "refer",
"type": "*",
"resource": "*"
}
]
}'
}
# https://api.gocd.org/current/#create-an-elastic-agent-profile
ElasticAgentProfile() {
curl $URL'/go/api/elastic/profiles' \
-H 'Accept: application/vnd.go.cd.v2+json' \
-H 'Content-Type: application/json' \
-X POST -d '{
"id": "buildah",
"cluster_profile_id": "k8-cluster-profile",
"properties": [
{
"key": "PodSpecType",
"value" : "yaml"
},
{
"key": "PodConfiguration",
"value" : "apiVersion: v1
kind: Pod
metadata:
name: gocd-agent-buildah
labels:
app: web
spec:
containers:
- name: gocd-agent-container-buildah
image: docker.io/jstrohm/gocd-agent-buildah
env:
- name: DOCKER_PASSWORD
valueFrom:
secretKeyRef:
name: docker-password
key: password
securityContext:
privileged: true"
}
]
}'
curl $URL'/go/api/elastic/profiles' \
-H 'Accept: application/vnd.go.cd.v2+json' \
-H 'Content-Type: application/json' \
-X POST -d '{
"id": "kubectl",
"cluster_profile_id": "k8-cluster-profile",
"properties": [
{
"key": "PodSpecType",
"value" : "yaml"
},
{
"key": "PodConfiguration",
"value" : "apiVersion: v1
kind: Pod
metadata:
name: gocd-agent-kubectl
labels:
app: web
spec:
containers:
- name: gocd-agent-container-kubectl
image: docker.io/jstrohm/gocd-agent-kubectl"
}
]
}'
}
ConfigRepo
ElasticAgentProfile