-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbootstrap.py
More file actions
26 lines (19 loc) · 801 Bytes
/
bootstrap.py
File metadata and controls
26 lines (19 loc) · 801 Bytes
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
import sys
from gomatic import GoCdConfigurator, HostRestClient, ExecTask
configurator = GoCdConfigurator(HostRestClient('go-server:8153'))
pipeline_name = sys.argv[1]
pipeline = configurator \
.ensure_pipeline_group('auto-created') \
.find_pipeline(pipeline_name)
for stage in pipeline.stages()[1:]:
pipeline.ensure_removal_of_stage(stage.name())
pipeline.ensure_stage('build').ensure_job('build') \
.ensure_task(ExecTask(['echo', 'build']))
environments = open('environments.txt').readlines()
for environment in environments:
if environment:
pipeline \
.ensure_stage('deploy-to-' + environment.strip()) \
.ensure_job('deploy') \
.ensure_task(ExecTask(['echo', 'deploy', 'to', 'environment']))
configurator.save_updated_config()