-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipelines.yml
executable file
·138 lines (136 loc) · 4.38 KB
/
pipelines.yml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
# A list of pipelines where each item is a YAML representation of https://api.go.cd/current/#the-pipeline-config-object
pipelines:
- group: example-service
pipeline_template: build
pipeline:
label_template: 1.${COUNT}.0
name: example-service-build
materials:
- type: git
attributes:
url: https://github.com/dennisgranath/example-service.git
branch: master
parameters:
- name: CONFIG_FILE
value: config.yml
- group: example-service
pipeline_template: deploy
pipeline:
label_template: ${example-service-build}
name: example-service-qa
materials:
- type: dependency
attributes:
pipeline: example-service-build
stage: Build
parameters:
- name: CONFIG_FILE
value: config.yml
- name: TARGET
value: app-server
- name: SERVICE_NAME
value: example-service
- name: UPSTREAM_PIPELINE
value: example-service-build
- name: UPSTREAM_STAGE
value: Build
- name: UPSTREAM_JOB
value: build
- group: example-service
pipeline_template: deploy
pipeline:
label_template: ${example-service-qa}
name: example-service-prod
materials:
- type: dependency
attributes:
pipeline: example-service-qa
stage: Deploy
parameters:
- name: CONFIG_FILE
value: config.yml
- name: TARGET
value: app-server
- name: SERVICE_NAME
value: example-service
- name: UPSTREAM_PIPELINE
value: example-service-qa
- name: UPSTREAM_STAGE
value: Deploy
- name: UPSTREAM_JOB
value: deploy
templates:
deploy:
pipeline:
stages:
- name: Deploy
jobs:
- name: deploy
artifacts:
- source: target
type: build
- source: '#{CONFIG_FILE}'
type: build
tasks:
- type: fetch
attributes:
pipeline: '#{UPSTREAM_PIPELINE}'
stage: '#{UPSTREAM_STAGE}'
job: '#{UPSTREAM_JOB}'
source: target
- type: fetch
attributes:
pipeline: '#{UPSTREAM_PIPELINE}'
stage: '#{UPSTREAM_STAGE}'
job: '#{UPSTREAM_JOB}'
source: '#{CONFIG_FILE}'
is_source_a_file: true
- type: exec
attributes:
command: /bin/bash
arguments:
- -c
- ansible all -i "#{TARGET}," -u root -m copy -a "src=target/#{SERVICE_NAME}-${GO_PIPELINE_LABEL}.jar dest=/root/#{SERVICE_NAME}.jar"
- type: exec
attributes:
command: /bin/bash
arguments:
- -c
- ansible all -i "#{TARGET}," -u root -m copy -a "src=#{CONFIG_FILE} dest=/root/config.yml"
- type: exec
attributes:
command: /bin/bash
arguments:
- -c
- ansible all -i "#{TARGET}," -u root -m shell -a "killall java || true"
- type: exec
attributes:
command: /bin/bash
arguments:
- -c
- ansible all -i "#{TARGET}," -u root -m shell -a "java -jar /root/#{SERVICE_NAME}.jar server /root/#{CONFIG_FILE} > app.out 2> app.err < /dev/null &"
build:
pipeline:
stages:
- name: Build
jobs:
- name: build
artifacts:
- source: target
type: build
- source: '#{CONFIG_FILE}'
type: build
tasks:
- type: exec
attributes:
command: /bin/bash
arguments:
- -c
- mvn versions:set -DnewVersion=${GO_PIPELINE_LABEL}
- type: exec
attributes:
command: /bin/bash
arguments:
- -c
- mvn clean install