blob: 42bcbeba0c11f9e31753d5367202cf28ba29612e [file] [log] [blame]
OlgaGusarenkof20d94d2018-07-30 18:48:25 +03001=====
2Usage
3=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +02004
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +04005Jenkins CI is an open source automation server written in Java. Jenkins
OlgaGusarenkof20d94d2018-07-30 18:48:25 +03006helps to automate the non-human part of software development process,
7with continuous integration and facilitating technical aspects of
8continuous delivery.
Dan Alvizu5d9336b2018-01-15 14:43:51 -07009
10More information can be found at `<https://jenkins.io/>`_
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020011
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030012Setup jenkins client, works with Salt 2016.3+, supports pipeline
13workflow projects only for now.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020014
Dan Alvizu5d9336b2018-01-15 14:43:51 -070015Dependencies
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030016============
Dan Alvizu5d9336b2018-01-15 14:43:51 -070017
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030018To install on Ubuntu, you will need to add the jenkins debian repository
19to the target server. You can do this with the
Pavel Cizinskye8cb7a02018-12-12 12:02:10 +010020`salt-formula-linux formula <https://gerrit.mcp.mirantis.com/salt-formulas/linux>`_ ,
Dan Alvizu5d9336b2018-01-15 14:43:51 -070021with the following pillar data:
22
23.. code-block:: yaml
24
25 linux:
26 system:
27 enabled: true
28 repo:
29 jenkins:
30 enabled: true
31 source: "deb http://pkg.jenkins.io/debian-stable binary/"
32 key_url: "https://pkg.jenkins.io/debian/jenkins-ci.org.key"
33
34This state will need to be applied *before* the jenkins state.
35
36Using this formula
37==================
38
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030039To use this formula, you must install the formula to your Salt
40Master as documented in
41`saltstack formula docs <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#installation>`_
Dan Alvizu5d9336b2018-01-15 14:43:51 -070042
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030043This formula is driven by pillar data, and can be used to
44install either a Jenkins Master or Client. See pillar data
45below for examples.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020046
Ales Komareke5a1ed62016-08-27 12:02:48 +020047Sample pillars
48==============
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020049
Ales Komarekffe8bb22017-02-09 11:10:16 +010050Master role
51-----------
Ales Komareke5a1ed62016-08-27 12:02:48 +020052
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030053Simple master with reverse proxy:
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020054
55.. code-block:: yaml
56
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020057 nginx:
58 server:
59 site:
60 jenkins:
61 enabled: true
62 type: nginx_proxy
63 name: jenkins
64 proxy:
65 host: 127.0.0.1
66 port: 8080
67 protocol: http
68 host:
69 name: jenkins.example.com
70 port: 80
71 jenkins:
72 master:
73 mode: EXCLUSIVE
Alexander Evseev2c494d72018-08-01 11:52:18 +020074 java_args: -Xms256m -Xmx1g
Alexander Evseev1ed23bf2018-08-02 12:12:19 +020075 # Do not manage any xml config files via Salt, use UI instead
76 # Including config.xml and any plugin xml's.
Filip Pytloun52b9c2c2016-01-28 13:45:57 +010077 no_config: true
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020078 slaves:
79 - name: slave01
80 label: pbuilder
81 executors: 2
82 - name: slave02
83 label: image_builder
84 mode: EXCLUSIVE
85 executors: 2
86 views:
87 - name: "Package builds"
88 regex: "debian-build-.*"
89 - name: "Contrail builds"
90 regex: "contrail-build-.*"
91 - name: "Aptly"
92 regex: "aptly-.*"
93 plugins:
94 - name: slack
95 - name: extended-choice-parameter
96 - name: rebuild
97 - name: test-stability
98
OlgaGusarenkof20d94d2018-07-30 18:48:25 +030099Jenkins master with experimental plugin source support:
Ales Komarekaf967ee2016-08-31 19:38:50 +0200100
101.. code-block:: yaml
102
103 jenkins:
104 master:
105 enabled: true
106 update_site_url: 'http://updates.jenkins-ci.org/experimental/update-center.json'
107
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300108SMTP server settings:
Ales Komarekaf967ee2016-08-31 19:38:50 +0200109
Ales Komarekffe8bb22017-02-09 11:10:16 +0100110.. code-block:: yaml
111
112 jenkins:
113 master:
114 email:
115 engine: "smtp"
116 host: "smtp.domain.com"
117 user: "user@domain.cz"
118 password: "smtp-password"
119 port: 25
120
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300121Script approvals from client:
Jakub Josefbf0b73e2017-03-22 14:32:45 +0100122
123.. code-block:: yaml
124
125 jenkins:
126 client:
127 approved_scripts:
128 - method groovy.json.JsonSlurperClassic parseText java.lang.String
129
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300130Script approvals:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100131
132.. code-block:: yaml
133
134 jenkins:
135 master:
136 approved_scripts:
137 - method groovy.json.JsonSlurperClassic parseText java.lang.String
138
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300139User enforcement:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100140
141.. code-block:: yaml
142
143 jenkins:
144 master:
145 user:
146 admin:
147 api_token: xxxxxxxxxx
148 password: admin_password
149 email: admin@domain.com
150 user01:
151 api_token: xxxxxxxxxx
152 password: user_password
153 email: user01@domain.com
154
Ales Komarekffe8bb22017-02-09 11:10:16 +0100155Agent (slave) role
156------------------
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200157
158.. code-block:: yaml
159
Ales Komarek4c0bab12016-01-22 12:10:50 +0100160 jenkins:
161 slave:
162 master:
163 host: jenkins.example.com
164 port: 80
Michael Kutý37a35952016-06-10 23:51:36 +0200165 protocol: http
Ales Komarek4c0bab12016-01-22 12:10:50 +0100166 user:
167 name: jenkins_slave
168 password: dexiech6AepohthaiHook2iesh7ol5ook4Ov3leid3yek6daid2ooNg3Ee2oKeYo
169 gpg:
170 keypair_id: A76882D3
171 public_key: |
172 -----BEGIN PGP PUBLIC KEY BLOCK-----
173 ...
174 private_key: |
175 -----BEGIN PGP PRIVATE KEY BLOCK-----
176 ...
Ales Komarekaf967ee2016-08-31 19:38:50 +0200177
Ales Komarekffe8bb22017-02-09 11:10:16 +0100178Client role
179-----------
Ales Komareke5a1ed62016-08-27 12:02:48 +0200180
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300181Simple client with workflow job definition:
Ales Komareke5a1ed62016-08-27 12:02:48 +0200182
183.. code-block:: yaml
184
185 jenkins:
186 client:
187 master:
188 host: jenkins.example.com
189 port: 80
190 protocol: http
Ivan Berezovskiyf28ee092019-02-12 17:16:30 +0400191 location:
192 url: http://jenkins.example.com:80
Ales Komareke5a1ed62016-08-27 12:02:48 +0200193 job:
194 jobname:
195 type: workflow
196 param:
197 bool_param:
198 type: boolean
199 description: true/false
200 default: true
201 string_param:
202 type: string
203 description: 1 liner
204 default: default_string
205 text_param:
206 type: text
207 description: multi-liner
208 default: default_text
Filip Pytlounebd4d172016-09-01 14:23:20 +0200209 jobname_scm:
210 type: workflow-scm
211 concurrent: false
212 scm:
213 type: git
214 url: https://github.com/jenkinsci/docker.git
215 branch: master
216 script: Jenkinsfile
217 github:
218 url: https://github.com/jenkinsci/docker
219 name: "Jenkins Docker Image"
220 trigger:
Tomáš Kukrála9cf2c62017-03-04 11:25:20 +0100221 timer:
John Doe645e6b02018-12-18 19:54:17 +0000222 dependency_job_names:
223 - job1
224 - job2
Tomáš Kukrála9cf2c62017-03-04 11:25:20 +0100225 spec: "H H * * *"
Filip Pytlounebd4d172016-09-01 14:23:20 +0200226 github:
227 pollscm:
228 spec: "H/15 * * * *"
229 reverse:
230 projects:
231 - test1
232 - test2
233 state: SUCCESS
234 param:
235 bool_param:
236 type: boolean
237 description: true/false
238 default: true
239 string_param:
240 type: string
241 description: 1 liner
242 default: default_string
243 text_param:
244 type: text
245 description: multi-liner
246 default: default_text
Ales Komareke5a1ed62016-08-27 12:02:48 +0200247
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300248Inline Groovy scripts:
Ales Komareke5a1ed62016-08-27 12:02:48 +0200249
250.. code-block:: yaml
251
252 jenkins:
253 client:
254 job:
255 test_workflow_jenkins_simple:
256 type: workflow
257 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200258 script:
259 content: |
260 node {
261 stage 'Stage 1'
262 echo 'Hello World 1'
263 stage 'Stage 2'
264 echo 'Hello World 2'
265 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200266 test_workflow_jenkins_input:
267 type: workflow
268 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200269 script:
270 content: |
271 node {
272 stage 'Enter string'
273 input message: 'Enter job parameters', ok: 'OK', parameters: [
274 string(defaultValue: 'default', description: 'Enter a string.', name: 'string'),
275 ]
276 stage 'Enter boolean'
277 input message: 'Enter job parameters', ok: 'OK', parameters: [
278 booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'),
279 ]
280 stage 'Enter text'
281 input message: 'Enter job parameters', ok: 'OK', parameters: [
282 text(defaultValue: '', description: 'Enter multiline', name: 'Multiline')
283 ]
284 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200285
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300286GIT controlled groovy scripts:
Ales Komarekdaf31f72016-08-29 11:00:13 +0200287
288.. code-block:: yaml
289
290 jenkins:
291 client:
292 source:
Ales Komarek5b672fd2016-08-29 16:05:03 +0200293 base:
294 engine: git
295 address: repo_url
296 branch: branch
297 domain:
298 engine: git
299 address: domain_url
300 branch: branch
Ales Komarekdaf31f72016-08-29 11:00:13 +0200301 job:
302 test_workflow_jenkins_simple:
303 type: workflow
304 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200305 param:
306 bool_param:
307 type: boolean
308 description: true/false
309 default: true
310 script:
311 repository: base
312 file: workflows/test_workflow_jenkins_simple.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200313 test_workflow_jenkins_input:
314 type: workflow
315 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200316 script:
317 repository: domain
318 file: workflows/test_workflow_jenkins_input.groovy
319 test_workflow_jenkins_input_jenkinsfile:
320 type: workflow
321 display_name: Test jenkins workflow inputs (jenknisfile)
322 script:
323 repository: domain
324 file: workflows/test_workflow_jenkins_input/Jenkinsfile
Ales Komarekdaf31f72016-08-29 11:00:13 +0200325
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300326GIT controlled groovy script with shared libraries:
Ales Komarek5b672fd2016-08-29 16:05:03 +0200327
328.. code-block:: yaml
329
330 jenkins:
331 client:
332 source:
333 base:
334 engine: git
335 address: repo_url
336 branch: branch
337 domain:
338 engine: git
339 address: domain_url
340 branch: branch
341 job:
342 test_workflow_jenkins_simple:
343 type: workflow
344 display_name: Test jenkins simple workflow
345 param:
346 bool_param:
347 type: boolean
348 description: true/false
349 default: true
350 script:
351 repository: base
352 file: workflows/test_workflow_jenkins_simple.groovy
353 libs:
354 - repository: base
355 file: macros/cookiecutter.groovy
356 - repository: base
357 file: macros/git.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200358
Jakub Josef120714d2017-02-09 16:29:18 +0100359Setting job max builds to keep (amount of last builds stored on Jenkins master)
360
361.. code-block:: yaml
362
363 jenkins:
364 client:
365 job:
366 my-amazing-job:
367 type: workflow
368 discard:
369 build:
370 keep_num: 5
371 keep_days: 5
372 artifact:
373 keep_num: 6
374 keep_days: 6
375
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300376Using job templates in similar way as in jjb. For now just
3771 defined param is supported:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100378
379.. code-block:: yaml
380
381 jenkins:
382 client:
383 job_template:
384 test_workflow_template:
385 name: test-{{formula}}-workflow
386 template:
387 type: workflow
388 display_name: Test jenkins {{name}} workflow
389 param:
390 repo_param:
391 type: string
392 default: repo/{{formula}}
393 script:
394 repository: base
395 file: workflows/test_formula_workflow.groovy
396 param:
397 formula:
398 - aodh
399 - linux
400 - openssh
401
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300402Interpolating parameters for job templates:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100403
Filip Pytloun83129fc2017-02-23 10:07:32 +0100404.. code-block:: yaml
405
Ales Komarekffe8bb22017-02-09 11:10:16 +0100406 _param:
407 salt_formulas:
408 - aodh
409 - git
410 - nova
411 - xorg
412 jenkins:
413 client:
414 job_template:
415 test_workflow_template:
416 name: test-{{formula}}-workflow
417 template:
418 ...
419 param:
420 formula: ${_param:salt_formulas}
421
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300422Or simply define multiple jobs and it's parameters to
423replace from template:
Filip Pytloun83129fc2017-02-23 10:07:32 +0100424
425.. code-block:: yaml
426
427 jenkins:
428 client:
429 job_template:
430 test_workflow_template:
431 name: test-{{name}}-{{myparam}}
432 template:
433 ...
434 jobs:
435 - name: firstjob
436 myparam: dummy
437 - name: secondjob
438 myparam: dummyaswell
Ales Komarekffe8bb22017-02-09 11:10:16 +0100439
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300440Purging undefined jobs from Jenkins:
Jakub Josef2a7739b2017-01-24 18:33:44 +0100441
442.. code-block:: yaml
443
444 jenkins:
445 client:
446 purge_jobs: true
Ales Komarekffe8bb22017-02-09 11:10:16 +0100447 job:
448 my-amazing-job:
449 type: workflow
Jakub Josef2a7739b2017-01-24 18:33:44 +0100450
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300451Plugins management from client:
Jakub Josef10b4e102017-01-05 18:18:41 +0100452
453.. code-block:: yaml
454
Jakub Josef10b4e102017-01-05 18:18:41 +0100455 jenkins:
456 client:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200457 plugin_remove_unwanted: false
458 plugin_force_remove: false
Jakub Josef10b4e102017-01-05 18:18:41 +0100459 plugin:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200460 plugin1: 1.2.3
461 plugin2:
462 plugin3: {}
463 plugin4:
464 version: 3.2.1
Jakub Josef10b4e102017-01-05 18:18:41 +0100465 enabled: false
Alexander Evseevcd836a12018-07-27 13:02:45 +0200466 plugin5: absent
Jakub Josef10b4e102017-01-05 18:18:41 +0100467
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300468Adding plugin params to job:
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200469
470.. code-block:: yaml
471
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200472 jenkins:
473 client:
474 job:
475 my_plugin_parametrized_job:
476 plugin_properties:
477 throttleconcurrents:
478 enabled: True
479 max_concurrent_per_node: 3
Vasyl Saienko661acf42018-01-18 10:37:07 +0200480 max_concurrent_total: 1
481 throttle_option: category #one of project (default or category)
482 categories:
483 - my_throuttle_category
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200484 plugin:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200485 throttle-concurrents:
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200486
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300487LDAP configuration (depends on LDAP plugin):
Jakub Josef063a7532017-01-11 15:48:01 +0100488
489.. code-block:: yaml
490
491 jenkins:
492 client:
493 security:
494 ldap:
495 server: 1.2.3.4
496 root_dn: dc=foo,dc=com
497 user_search_base: cn=users,cn=accounts
498 manager_dn: ""
499 manager_password: password
500 user_search: ""
501 group_search_base: ""
502 inhibit_infer_root_dn: false
503
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300504Matrix configuration (depends on auth-matrix plugin):
Jakub Josef063a7532017-01-11 15:48:01 +0100505
506.. code-block:: yaml
507
508 jenkins:
509 client:
510 security:
511 matrix:
Jakub Josef0ee470e2017-01-17 11:46:58 +0100512 # set true for use ProjectMatrixAuthStrategy instead of GlobalMatrixAuthStrategy
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400513 project_based: false
Jakub Josef063a7532017-01-11 15:48:01 +0100514 permissions:
515 Jenkins:
516 # administrator access
517 ADMINISTER:
518 - admin
519 # read access (anonymous too)
520 READ:
521 - anonymous
522 - user1
523 - user2
524 # agents permissions
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400525 MasterComputer:
526 BUILD:
Jakub Josef063a7532017-01-11 15:48:01 +0100527 - user3
528 # jobs permissions
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400529 hudson:
Jakub Josef063a7532017-01-11 15:48:01 +0100530 model:
531 Item:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400532 BUILD:
Jakub Josef063a7532017-01-11 15:48:01 +0100533 - user4
534
535`Common matrix strategies <https://github.com/arbabnazar/configuration/blob/c08a5eaf4e04a68d2481375502a926517097b253/playbooks/roles/tools_jenkins/templates/projectBasedMatrixSecurity.groovy.j2>`_
536
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300537Views enforcing from client:
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100538
539.. code-block:: yaml
540
541 jenkins:
542 client:
543 view:
544 my-list-view:
545 enabled: true
546 type: ListView
Jakub Josef7d9fce32017-03-24 16:46:56 +0100547 include_regex: ".*"
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100548 my-view:
549 # set false to disable
550 enabled: true
551 type: MyView
552
553View specific params:
554
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300555- ``include_regex`` for ``ListView`` and ``CategorizedJobsView``
556- categories for ``CategorizedJobsView``
Jakub Josef7d9fce32017-03-24 16:46:56 +0100557
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300558Categorized views:
Jakub Josef7d9fce32017-03-24 16:46:56 +0100559
560.. code-block:: yaml
561
562 jenkins:
563 client:
564 view:
565 my-categorized-view:
566 enabled: true
567 type: CategorizedJobsView
568 include_regex: ".*"
569 categories:
570 - group_regex: "aptly-.*-nightly-testing"
571 naming_rule: "Nightly -> Testing"
572 - group_regex: "aptly-.*-nightly-production"
573 naming_rule: "Nightly -> Production"
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100574
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300575Credentials enforcing from client:
Jakub Josef123be7a2016-12-12 16:02:36 +0100576
577.. code-block:: yaml
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200578
Jakub Josef123be7a2016-12-12 16:02:36 +0100579 jenkins:
580 client:
581 credential:
582 cred_first:
583 username: admin
584 password: password
585 cred_second:
586 username: salt
587 password: password
588 cred_with_key:
589 username: admin
590 key: SOMESSHKEY
Sergey Otpuschennikov1dd77992018-06-27 11:11:07 +0400591 cred_with_text_secret:
592 secret: SOMETEXTSECRET
Yuriy Taraday2e21e3c2018-02-06 20:17:58 +0400593 cred_with_secret_file:
594 filename: somefile.json
595 content: |
596 { "Hello": "world!" }
Jakub Josef123be7a2016-12-12 16:02:36 +0100597
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300598Users enforcing from client:
Jakub Josef123be7a2016-12-12 16:02:36 +0100599
600.. code-block:: yaml
601
602 jenkins:
603 client:
604 user:
605 admin:
606 password: admin_password
607 admin: true
608 user01:
609 password: user_password
610
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300611Node enforcing from client using JNLP launcher:
Jakub Josef123be7a2016-12-12 16:02:36 +0100612
613.. code-block:: yaml
614
615 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100616 client:
617 node:
618 node01:
619 remote_home: /remote/home/path
620 desc: node-description
621 num_executors: 1
622 node_mode: Normal
623 ret_strategy: Always
624 labels:
625 - example
626 - label
627 launcher:
628 type: jnlp
Jakub Josef123be7a2016-12-12 16:02:36 +0100629
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300630Node enforcing from client using SSH launcher:
Jakub Josef123be7a2016-12-12 16:02:36 +0100631
632.. code-block:: yaml
633
634 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100635 client:
636 node:
637 node01:
638 remote_home: /remote/home/path
639 desc: node-description
640 num_executors: 1
641 node_mode: Normal
642 ret_strategy: Always
643 labels:
644 - example
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200645 - label
Ales Komarekffe8bb22017-02-09 11:10:16 +0100646 launcher:
647 type: ssh
648 host: test-launcher
649 port: 22
650 username: launcher-user
651 password: launcher-pass
Jakub Josef123be7a2016-12-12 16:02:36 +0100652
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300653Configure Jenkins master:
Jakub Josef1bb7f442017-05-26 17:02:56 +0200654
655.. code-block:: yaml
656
657 jenkins:
658 client:
659 node:
660 master:
661 num_executors: 1
662 node_mode: Normal # or Exclusive
663 labels:
664 - example
665 - label
666
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300667Setting node labels:
Jakub Josef123be7a2016-12-12 16:02:36 +0100668
669.. code-block:: yaml
670
671 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100672 client:
673 label:
674 node-name:
675 lbl_text: label-offline
676 append: false # set true for label append instead of replace
Jakub Josefd8e04292016-11-28 18:02:27 +0100677
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300678SMTP server settings from client:
Jakub Josef60cc9d22017-01-18 12:02:14 +0100679
680.. code-block:: yaml
681
682 jenkins:
683 client:
684 smtp:
685 host: "smtp.domain.com"
686 username: "user@domain.cz"
687 password: "smtp-password"
688 port: 25
689 ssl: false
690 reply_to: reply_to@address.com
691
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300692Jenkins admin user email enforcement from client:
Jakub Josefdfb288c2017-04-27 17:29:00 +0200693
694.. code-block:: yaml
695
696 jenkins:
697 client:
698 smtp:
699 admin_email: "My Jenkins <jenkins@myserver.com>"
700
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300701Slack plugin configuration:
Jakub Josefa6d4c832017-01-19 14:06:12 +0100702
703.. code-block:: yaml
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400704
Jakub Josefa6d4c832017-01-19 14:06:12 +0100705 jenkins:
706 client:
707 slack:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100708 team_domain: example.com
709 token: slack-token
710 room: slack-room
Jakub Josef6e0cda92017-02-14 18:01:58 +0100711 token_credential_id: cred_id
Ales Komarekffe8bb22017-02-09 11:10:16 +0100712 send_as: Some slack user
Jakub Josefa6d4c832017-01-19 14:06:12 +0100713
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300714Pipeline global libraries setup:
Jakub Josef6e0cda92017-02-14 18:01:58 +0100715
716.. code-block:: yaml
717
718 jenkins:
719 client:
720 lib:
721 my-pipeline-library:
722 enabled: true
723 url: https://path-to-my-library
724 credential_id: github
725 branch: master # optional, default master
726 implicit: true # optional default true
Jakub Josefd8e04292016-11-28 18:02:27 +0100727
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300728Artifactory server enforcing:
Jakub Josef01940252017-05-10 14:01:22 +0200729
730.. code-block:: yaml
731
732 jenkins:
733 client:
734 artifactory:
735 my-artifactory-server:
736 enabled: true
737 url: https://path-to-my-library
738 credential_id: github
739
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300740Jenkins Global env properties enforcing:
Jakub Josef184ee1c2017-11-29 16:03:09 +0100741
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400742.. code-block:: yaml
Jakub Josef184ee1c2017-11-29 16:03:09 +0100743
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400744 jenkins:
745 client:
746 globalenvprop:
747 OFFLINE_DEPLOYMENT:
748 enabled: true
749 name: "OFFLINE_DEPLOYMENT" # optional, default using dict key
750 value: "true"
Jakub Josef184ee1c2017-11-29 16:03:09 +0100751
Dmitry Burmistrova3f2c132018-04-10 16:24:25 +0400752Throttle categories management from client (requires
753`Throttle Concurrent Builds <https://plugins.jenkins.io/throttle-concurrents>`_
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300754plugin):
Dmitry Burmistrova3f2c132018-04-10 16:24:25 +0400755
756.. code-block:: yaml
757
758 jenkins:
759 client:
760 throttle_category:
761 'My First Category':
762 max_total: 2
763 max_per_node: 1
764 'My Second Category':
765 max_total: 5
766 max_per_node: 2
767 max_per_label:
768 'node_label_1': 1
769 'node_label_2': 2
770 'My Category To Remove:
771 enabled: false
772
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400773Jira sites management from client (requires
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300774`JIRA <https://plugins.jenkins.io/jira>`_ plugin):
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400775
776.. code-block:: yaml
777
778 # Remove all sites
779 jenkins:
780 client:
781 jira:
782 enabled: False
783
784.. code-block:: yaml
785
786 jenkins:
787 client:
788 jira:
789 sites:
790 'http://my.jira.site/':
791 link_url: 'http://alternative.link/'
792 http_auth: false
793 use_wiki_notation: false
794 record_scm: false
795 disable_changelog: false
796 issue_pattern: ''
797 any_build_result: false
798 user: 'username'
799 password: 'passwd'
800 conn_timeout: 10
801 visible_for_group: ''
802 visible_for_project: ''
803 timestamps: false
804 timestamp_format: ''
Sergey Otpuschennikov74ea2682018-05-21 16:35:36 +0400805
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300806Gerrit trigger plugin configuration:
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400807
808.. code-block:: yaml
809
810 jenkins:
811 client:
812 gerrit:
813 server1:
814 host: "gerrit.domain.local"
815 port: 29418
816 username: "jenkins"
817 email: "jenkins@domain.local"
818 auth_key_file: "/var/jenkins_home/.ssh/id_rsa"
819 frontendURL: "https://gerrit.domain.local"
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +0400820 build_current_patches_only: true
821 abort_new_patchsets: false
822 abort_manual_patchsets: false
823 abort_same_topic: false
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400824 authkey: |
825 SOMESSHKEY
826 server2:
827 host: "gerrit2.domain.local"
828 port: 29418
829 username: "jenkins"
830 email: "jenkins@domain.local"
831 auth_key_file: "/var/jenkins_home/.ssh/id_rsa"
832 frontendURL: "https://gerrit2.domain.local"
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +0400833 build_current_patches_only: true
834 abort_new_patchsets: false
835 abort_manual_patchsets: false
836 abort_same_topic: false
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400837 authkey: |
838 SOMESSHKEY
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400839
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300840CSRF Protection configuration:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400841
842.. code-block:: yaml
843
844 jenkins:
845 client:
846 security:
847 csrf:
848 enabled: true
849 proxy_compat: false
850
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300851Agent to Master Access Control:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400852
853.. code-block:: yaml
854
855 jenkins:
856 client:
857 security:
858 agent2master:
859 enabled: true
860 whitelisted: ''
861 file_path_rules: ''
862
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300863Content Security Policy configuration:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400864
865.. code-block:: yaml
866
867 jenkins:
868 client:
869 security:
870 csp: "sandbox; default-src 'none'; img-src 'self'; style-src 'self';"
871
Ales Komarek4c0bab12016-01-22 12:10:50 +0100872Usage
873=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200874
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300875#. Generate password hash:
Ales Komarek4c0bab12016-01-22 12:10:50 +0100876
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300877 .. code-block:: bash
Ales Komarek4c0bab12016-01-22 12:10:50 +0100878
879 echo -n "salt{plainpassword}" | openssl dgst -sha256
880
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300881#. Place in the configuration ``salt:hashpassword``.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200882
Ales Komarekffe8bb22017-02-09 11:10:16 +0100883
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300884Read more
885=========
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200886
887* https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins