blob: 44fe5bacbf9d61861e4d5cb4246de7052e755235 [file] [log] [blame]
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +02001=======
2Jenkins
3=======
4
Ales Komarek4c0bab12016-01-22 12:10:50 +01005Jenkins is an application that monitors executions of repeated jobs, such as building a software project or jobs run by cron.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +02006
7Available states
8================
9
10.. contents::
11 :local:
12
13``jenkins.master``
14------------------
15
Ales Komareke5a1ed62016-08-27 12:02:48 +020016Setup jenkins master.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020017
18``jenkins.slave``
19-----------------
20
Ales Komareke5a1ed62016-08-27 12:02:48 +020021Setup jenkins slave.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020022
23``jenkins.job_builder``
24-----------------------
25
Ales Komareke5a1ed62016-08-27 12:02:48 +020026Setup jenkins job builder.
27
28``jenkins.client``
29------------------
30
31Setup jenkins client, works with Salt 2016.3+, supports pipeline workflow projects only now.
32
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020033
34Available metadata
35==================
36
37.. contents::
38 :local:
39
40``metadata.jenkins.master.single``
41----------------------------------
42
43Setup single-node master
44
45
46``metadata.jenkins.slave.single``
47---------------------------------
48
49Setup Jenkins slave
50
Ales Komareke5a1ed62016-08-27 12:02:48 +020051Sample pillars
52==============
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020053
Ales Komarek4c0bab12016-01-22 12:10:50 +010054Jenkins master
Ales Komareke5a1ed62016-08-27 12:02:48 +020055--------------
56
57Simple master with reverse proxy
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020058
59.. code-block:: yaml
60
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020061 nginx:
62 server:
63 site:
64 jenkins:
65 enabled: true
66 type: nginx_proxy
67 name: jenkins
68 proxy:
69 host: 127.0.0.1
70 port: 8080
71 protocol: http
72 host:
73 name: jenkins.example.com
74 port: 80
75 jenkins:
76 master:
77 mode: EXCLUSIVE
Filip Pytloun52b9c2c2016-01-28 13:45:57 +010078 # Do not manage config.xml from Salt, use UI instead
79 no_config: true
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020080 slaves:
81 - name: slave01
82 label: pbuilder
83 executors: 2
84 - name: slave02
85 label: image_builder
86 mode: EXCLUSIVE
87 executors: 2
88 views:
89 - name: "Package builds"
90 regex: "debian-build-.*"
91 - name: "Contrail builds"
92 regex: "contrail-build-.*"
93 - name: "Aptly"
94 regex: "aptly-.*"
95 plugins:
96 - name: slack
97 - name: extended-choice-parameter
98 - name: rebuild
99 - name: test-stability
100
Ales Komarekaf967ee2016-08-31 19:38:50 +0200101Jenkins with experimental plugin source support
102
103.. code-block:: yaml
104
105 jenkins:
106 master:
107 enabled: true
108 update_site_url: 'http://updates.jenkins-ci.org/experimental/update-center.json'
109
110
Ales Komareke5a1ed62016-08-27 12:02:48 +0200111Agent (former slave)
112--------------------
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200113
114.. code-block:: yaml
115
Ales Komarek4c0bab12016-01-22 12:10:50 +0100116 jenkins:
117 slave:
118 master:
119 host: jenkins.example.com
120 port: 80
Michael Kutý37a35952016-06-10 23:51:36 +0200121 protocol: http
Ales Komarek4c0bab12016-01-22 12:10:50 +0100122 user:
123 name: jenkins_slave
124 password: dexiech6AepohthaiHook2iesh7ol5ook4Ov3leid3yek6daid2ooNg3Ee2oKeYo
125 gpg:
126 keypair_id: A76882D3
127 public_key: |
128 -----BEGIN PGP PUBLIC KEY BLOCK-----
129 ...
130 private_key: |
131 -----BEGIN PGP PRIVATE KEY BLOCK-----
132 ...
Ales Komarekaf967ee2016-08-31 19:38:50 +0200133
Ales Komareke5a1ed62016-08-27 12:02:48 +0200134Client
135------
136
137Simple client with workflow job definition
138
139.. code-block:: yaml
140
141 jenkins:
142 client:
143 master:
144 host: jenkins.example.com
145 port: 80
146 protocol: http
147 job:
148 jobname:
149 type: workflow
150 param:
151 bool_param:
152 type: boolean
153 description: true/false
154 default: true
155 string_param:
156 type: string
157 description: 1 liner
158 default: default_string
159 text_param:
160 type: text
161 description: multi-liner
162 default: default_text
163
Ales Komarekdaf31f72016-08-29 11:00:13 +0200164Inline Groovy script samples
Ales Komareke5a1ed62016-08-27 12:02:48 +0200165
166.. code-block:: yaml
167
168 jenkins:
169 client:
170 job:
171 test_workflow_jenkins_simple:
172 type: workflow
173 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200174 script:
175 content: |
176 node {
177 stage 'Stage 1'
178 echo 'Hello World 1'
179 stage 'Stage 2'
180 echo 'Hello World 2'
181 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200182 test_workflow_jenkins_input:
183 type: workflow
184 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200185 script:
186 content: |
187 node {
188 stage 'Enter string'
189 input message: 'Enter job parameters', ok: 'OK', parameters: [
190 string(defaultValue: 'default', description: 'Enter a string.', name: 'string'),
191 ]
192 stage 'Enter boolean'
193 input message: 'Enter job parameters', ok: 'OK', parameters: [
194 booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'),
195 ]
196 stage 'Enter text'
197 input message: 'Enter job parameters', ok: 'OK', parameters: [
198 text(defaultValue: '', description: 'Enter multiline', name: 'Multiline')
199 ]
200 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200201
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200202
Ales Komarekdaf31f72016-08-29 11:00:13 +0200203GIT controlled groovy script samples
204
205.. code-block:: yaml
206
207 jenkins:
208 client:
209 source:
Ales Komarek5b672fd2016-08-29 16:05:03 +0200210 base:
211 engine: git
212 address: repo_url
213 branch: branch
214 domain:
215 engine: git
216 address: domain_url
217 branch: branch
Ales Komarekdaf31f72016-08-29 11:00:13 +0200218 job:
219 test_workflow_jenkins_simple:
220 type: workflow
221 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200222 param:
223 bool_param:
224 type: boolean
225 description: true/false
226 default: true
227 script:
228 repository: base
229 file: workflows/test_workflow_jenkins_simple.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200230 test_workflow_jenkins_input:
231 type: workflow
232 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200233 script:
234 repository: domain
235 file: workflows/test_workflow_jenkins_input.groovy
236 test_workflow_jenkins_input_jenkinsfile:
237 type: workflow
238 display_name: Test jenkins workflow inputs (jenknisfile)
239 script:
240 repository: domain
241 file: workflows/test_workflow_jenkins_input/Jenkinsfile
Ales Komarekdaf31f72016-08-29 11:00:13 +0200242
Ales Komarek5b672fd2016-08-29 16:05:03 +0200243GIT controlled groovy script with shared libraries
244
245.. code-block:: yaml
246
247 jenkins:
248 client:
249 source:
250 base:
251 engine: git
252 address: repo_url
253 branch: branch
254 domain:
255 engine: git
256 address: domain_url
257 branch: branch
258 job:
259 test_workflow_jenkins_simple:
260 type: workflow
261 display_name: Test jenkins simple workflow
262 param:
263 bool_param:
264 type: boolean
265 description: true/false
266 default: true
267 script:
268 repository: base
269 file: workflows/test_workflow_jenkins_simple.groovy
270 libs:
271 - repository: base
272 file: macros/cookiecutter.groovy
273 - repository: base
274 file: macros/git.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200275
Ales Komarek4c0bab12016-01-22 12:10:50 +0100276Usage
277=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200278
Ales Komarek4c0bab12016-01-22 12:10:50 +0100279Generate password hash:
280
281.. code-block:: bash
282
283 echo -n "salt{plainpassword}" | openssl dgst -sha256
284
285Place in the configuration ``salt:hashpassword``.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200286
287Read more
288=========
289
290* https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins