blob: d21f47fa4045d42d2fb58dd4c24832f3eb46cd32 [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
191 job:
192 jobname:
193 type: workflow
194 param:
195 bool_param:
196 type: boolean
197 description: true/false
198 default: true
199 string_param:
200 type: string
201 description: 1 liner
202 default: default_string
203 text_param:
204 type: text
205 description: multi-liner
206 default: default_text
Filip Pytlounebd4d172016-09-01 14:23:20 +0200207 jobname_scm:
208 type: workflow-scm
209 concurrent: false
210 scm:
211 type: git
212 url: https://github.com/jenkinsci/docker.git
213 branch: master
214 script: Jenkinsfile
215 github:
216 url: https://github.com/jenkinsci/docker
217 name: "Jenkins Docker Image"
218 trigger:
Tomáš Kukrála9cf2c62017-03-04 11:25:20 +0100219 timer:
John Doe645e6b02018-12-18 19:54:17 +0000220 dependency_job_names:
221 - job1
222 - job2
Tomáš Kukrála9cf2c62017-03-04 11:25:20 +0100223 spec: "H H * * *"
Filip Pytlounebd4d172016-09-01 14:23:20 +0200224 github:
225 pollscm:
226 spec: "H/15 * * * *"
227 reverse:
228 projects:
229 - test1
230 - test2
231 state: SUCCESS
232 param:
233 bool_param:
234 type: boolean
235 description: true/false
236 default: true
237 string_param:
238 type: string
239 description: 1 liner
240 default: default_string
241 text_param:
242 type: text
243 description: multi-liner
244 default: default_text
Ales Komareke5a1ed62016-08-27 12:02:48 +0200245
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300246Inline Groovy scripts:
Ales Komareke5a1ed62016-08-27 12:02:48 +0200247
248.. code-block:: yaml
249
250 jenkins:
251 client:
252 job:
253 test_workflow_jenkins_simple:
254 type: workflow
255 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200256 script:
257 content: |
258 node {
259 stage 'Stage 1'
260 echo 'Hello World 1'
261 stage 'Stage 2'
262 echo 'Hello World 2'
263 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200264 test_workflow_jenkins_input:
265 type: workflow
266 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200267 script:
268 content: |
269 node {
270 stage 'Enter string'
271 input message: 'Enter job parameters', ok: 'OK', parameters: [
272 string(defaultValue: 'default', description: 'Enter a string.', name: 'string'),
273 ]
274 stage 'Enter boolean'
275 input message: 'Enter job parameters', ok: 'OK', parameters: [
276 booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'),
277 ]
278 stage 'Enter text'
279 input message: 'Enter job parameters', ok: 'OK', parameters: [
280 text(defaultValue: '', description: 'Enter multiline', name: 'Multiline')
281 ]
282 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200283
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300284GIT controlled groovy scripts:
Ales Komarekdaf31f72016-08-29 11:00:13 +0200285
286.. code-block:: yaml
287
288 jenkins:
289 client:
290 source:
Ales Komarek5b672fd2016-08-29 16:05:03 +0200291 base:
292 engine: git
293 address: repo_url
294 branch: branch
295 domain:
296 engine: git
297 address: domain_url
298 branch: branch
Ales Komarekdaf31f72016-08-29 11:00:13 +0200299 job:
300 test_workflow_jenkins_simple:
301 type: workflow
302 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200303 param:
304 bool_param:
305 type: boolean
306 description: true/false
307 default: true
308 script:
309 repository: base
310 file: workflows/test_workflow_jenkins_simple.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200311 test_workflow_jenkins_input:
312 type: workflow
313 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200314 script:
315 repository: domain
316 file: workflows/test_workflow_jenkins_input.groovy
317 test_workflow_jenkins_input_jenkinsfile:
318 type: workflow
319 display_name: Test jenkins workflow inputs (jenknisfile)
320 script:
321 repository: domain
322 file: workflows/test_workflow_jenkins_input/Jenkinsfile
Ales Komarekdaf31f72016-08-29 11:00:13 +0200323
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300324GIT controlled groovy script with shared libraries:
Ales Komarek5b672fd2016-08-29 16:05:03 +0200325
326.. code-block:: yaml
327
328 jenkins:
329 client:
330 source:
331 base:
332 engine: git
333 address: repo_url
334 branch: branch
335 domain:
336 engine: git
337 address: domain_url
338 branch: branch
339 job:
340 test_workflow_jenkins_simple:
341 type: workflow
342 display_name: Test jenkins simple workflow
343 param:
344 bool_param:
345 type: boolean
346 description: true/false
347 default: true
348 script:
349 repository: base
350 file: workflows/test_workflow_jenkins_simple.groovy
351 libs:
352 - repository: base
353 file: macros/cookiecutter.groovy
354 - repository: base
355 file: macros/git.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200356
Jakub Josef120714d2017-02-09 16:29:18 +0100357Setting job max builds to keep (amount of last builds stored on Jenkins master)
358
359.. code-block:: yaml
360
361 jenkins:
362 client:
363 job:
364 my-amazing-job:
365 type: workflow
366 discard:
367 build:
368 keep_num: 5
369 keep_days: 5
370 artifact:
371 keep_num: 6
372 keep_days: 6
373
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300374Using job templates in similar way as in jjb. For now just
3751 defined param is supported:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100376
377.. code-block:: yaml
378
379 jenkins:
380 client:
381 job_template:
382 test_workflow_template:
383 name: test-{{formula}}-workflow
384 template:
385 type: workflow
386 display_name: Test jenkins {{name}} workflow
387 param:
388 repo_param:
389 type: string
390 default: repo/{{formula}}
391 script:
392 repository: base
393 file: workflows/test_formula_workflow.groovy
394 param:
395 formula:
396 - aodh
397 - linux
398 - openssh
399
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300400Interpolating parameters for job templates:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100401
Filip Pytloun83129fc2017-02-23 10:07:32 +0100402.. code-block:: yaml
403
Ales Komarekffe8bb22017-02-09 11:10:16 +0100404 _param:
405 salt_formulas:
406 - aodh
407 - git
408 - nova
409 - xorg
410 jenkins:
411 client:
412 job_template:
413 test_workflow_template:
414 name: test-{{formula}}-workflow
415 template:
416 ...
417 param:
418 formula: ${_param:salt_formulas}
419
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300420Or simply define multiple jobs and it's parameters to
421replace from template:
Filip Pytloun83129fc2017-02-23 10:07:32 +0100422
423.. code-block:: yaml
424
425 jenkins:
426 client:
427 job_template:
428 test_workflow_template:
429 name: test-{{name}}-{{myparam}}
430 template:
431 ...
432 jobs:
433 - name: firstjob
434 myparam: dummy
435 - name: secondjob
436 myparam: dummyaswell
Ales Komarekffe8bb22017-02-09 11:10:16 +0100437
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300438Purging undefined jobs from Jenkins:
Jakub Josef2a7739b2017-01-24 18:33:44 +0100439
440.. code-block:: yaml
441
442 jenkins:
443 client:
444 purge_jobs: true
Ales Komarekffe8bb22017-02-09 11:10:16 +0100445 job:
446 my-amazing-job:
447 type: workflow
Jakub Josef2a7739b2017-01-24 18:33:44 +0100448
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300449Plugins management from client:
Jakub Josef10b4e102017-01-05 18:18:41 +0100450
451.. code-block:: yaml
452
Jakub Josef10b4e102017-01-05 18:18:41 +0100453 jenkins:
454 client:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200455 plugin_remove_unwanted: false
456 plugin_force_remove: false
Jakub Josef10b4e102017-01-05 18:18:41 +0100457 plugin:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200458 plugin1: 1.2.3
459 plugin2:
460 plugin3: {}
461 plugin4:
462 version: 3.2.1
Jakub Josef10b4e102017-01-05 18:18:41 +0100463 enabled: false
Alexander Evseevcd836a12018-07-27 13:02:45 +0200464 plugin5: absent
Jakub Josef10b4e102017-01-05 18:18:41 +0100465
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300466Adding plugin params to job:
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200467
468.. code-block:: yaml
469
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200470 jenkins:
471 client:
472 job:
473 my_plugin_parametrized_job:
474 plugin_properties:
475 throttleconcurrents:
476 enabled: True
477 max_concurrent_per_node: 3
Vasyl Saienko661acf42018-01-18 10:37:07 +0200478 max_concurrent_total: 1
479 throttle_option: category #one of project (default or category)
480 categories:
481 - my_throuttle_category
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200482 plugin:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200483 throttle-concurrents:
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200484
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300485LDAP configuration (depends on LDAP plugin):
Jakub Josef063a7532017-01-11 15:48:01 +0100486
487.. code-block:: yaml
488
489 jenkins:
490 client:
491 security:
492 ldap:
493 server: 1.2.3.4
494 root_dn: dc=foo,dc=com
495 user_search_base: cn=users,cn=accounts
496 manager_dn: ""
497 manager_password: password
498 user_search: ""
499 group_search_base: ""
500 inhibit_infer_root_dn: false
501
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300502Matrix configuration (depends on auth-matrix plugin):
Jakub Josef063a7532017-01-11 15:48:01 +0100503
504.. code-block:: yaml
505
506 jenkins:
507 client:
508 security:
509 matrix:
Jakub Josef0ee470e2017-01-17 11:46:58 +0100510 # set true for use ProjectMatrixAuthStrategy instead of GlobalMatrixAuthStrategy
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400511 project_based: false
Jakub Josef063a7532017-01-11 15:48:01 +0100512 permissions:
513 Jenkins:
514 # administrator access
515 ADMINISTER:
516 - admin
517 # read access (anonymous too)
518 READ:
519 - anonymous
520 - user1
521 - user2
522 # agents permissions
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400523 MasterComputer:
524 BUILD:
Jakub Josef063a7532017-01-11 15:48:01 +0100525 - user3
526 # jobs permissions
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400527 hudson:
Jakub Josef063a7532017-01-11 15:48:01 +0100528 model:
529 Item:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400530 BUILD:
Jakub Josef063a7532017-01-11 15:48:01 +0100531 - user4
532
533`Common matrix strategies <https://github.com/arbabnazar/configuration/blob/c08a5eaf4e04a68d2481375502a926517097b253/playbooks/roles/tools_jenkins/templates/projectBasedMatrixSecurity.groovy.j2>`_
534
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300535Views enforcing from client:
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100536
537.. code-block:: yaml
538
539 jenkins:
540 client:
541 view:
542 my-list-view:
543 enabled: true
544 type: ListView
Jakub Josef7d9fce32017-03-24 16:46:56 +0100545 include_regex: ".*"
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100546 my-view:
547 # set false to disable
548 enabled: true
549 type: MyView
550
551View specific params:
552
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300553- ``include_regex`` for ``ListView`` and ``CategorizedJobsView``
554- categories for ``CategorizedJobsView``
Jakub Josef7d9fce32017-03-24 16:46:56 +0100555
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300556Categorized views:
Jakub Josef7d9fce32017-03-24 16:46:56 +0100557
558.. code-block:: yaml
559
560 jenkins:
561 client:
562 view:
563 my-categorized-view:
564 enabled: true
565 type: CategorizedJobsView
566 include_regex: ".*"
567 categories:
568 - group_regex: "aptly-.*-nightly-testing"
569 naming_rule: "Nightly -> Testing"
570 - group_regex: "aptly-.*-nightly-production"
571 naming_rule: "Nightly -> Production"
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100572
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300573Credentials enforcing from client:
Jakub Josef123be7a2016-12-12 16:02:36 +0100574
575.. code-block:: yaml
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200576
Jakub Josef123be7a2016-12-12 16:02:36 +0100577 jenkins:
578 client:
579 credential:
580 cred_first:
581 username: admin
582 password: password
583 cred_second:
584 username: salt
585 password: password
586 cred_with_key:
587 username: admin
588 key: SOMESSHKEY
Sergey Otpuschennikov1dd77992018-06-27 11:11:07 +0400589 cred_with_text_secret:
590 secret: SOMETEXTSECRET
Yuriy Taraday2e21e3c2018-02-06 20:17:58 +0400591 cred_with_secret_file:
592 filename: somefile.json
593 content: |
594 { "Hello": "world!" }
Jakub Josef123be7a2016-12-12 16:02:36 +0100595
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300596Users enforcing from client:
Jakub Josef123be7a2016-12-12 16:02:36 +0100597
598.. code-block:: yaml
599
600 jenkins:
601 client:
602 user:
603 admin:
604 password: admin_password
605 admin: true
606 user01:
607 password: user_password
608
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300609Node enforcing from client using JNLP launcher:
Jakub Josef123be7a2016-12-12 16:02:36 +0100610
611.. code-block:: yaml
612
613 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100614 client:
615 node:
616 node01:
617 remote_home: /remote/home/path
618 desc: node-description
619 num_executors: 1
620 node_mode: Normal
621 ret_strategy: Always
622 labels:
623 - example
624 - label
625 launcher:
626 type: jnlp
Jakub Josef123be7a2016-12-12 16:02:36 +0100627
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300628Node enforcing from client using SSH launcher:
Jakub Josef123be7a2016-12-12 16:02:36 +0100629
630.. code-block:: yaml
631
632 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100633 client:
634 node:
635 node01:
636 remote_home: /remote/home/path
637 desc: node-description
638 num_executors: 1
639 node_mode: Normal
640 ret_strategy: Always
641 labels:
642 - example
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200643 - label
Ales Komarekffe8bb22017-02-09 11:10:16 +0100644 launcher:
645 type: ssh
646 host: test-launcher
647 port: 22
648 username: launcher-user
649 password: launcher-pass
Jakub Josef123be7a2016-12-12 16:02:36 +0100650
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300651Configure Jenkins master:
Jakub Josef1bb7f442017-05-26 17:02:56 +0200652
653.. code-block:: yaml
654
655 jenkins:
656 client:
657 node:
658 master:
659 num_executors: 1
660 node_mode: Normal # or Exclusive
661 labels:
662 - example
663 - label
664
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300665Setting node labels:
Jakub Josef123be7a2016-12-12 16:02:36 +0100666
667.. code-block:: yaml
668
669 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100670 client:
671 label:
672 node-name:
673 lbl_text: label-offline
674 append: false # set true for label append instead of replace
Jakub Josefd8e04292016-11-28 18:02:27 +0100675
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300676SMTP server settings from client:
Jakub Josef60cc9d22017-01-18 12:02:14 +0100677
678.. code-block:: yaml
679
680 jenkins:
681 client:
682 smtp:
683 host: "smtp.domain.com"
684 username: "user@domain.cz"
685 password: "smtp-password"
686 port: 25
687 ssl: false
688 reply_to: reply_to@address.com
689
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300690Jenkins admin user email enforcement from client:
Jakub Josefdfb288c2017-04-27 17:29:00 +0200691
692.. code-block:: yaml
693
694 jenkins:
695 client:
696 smtp:
697 admin_email: "My Jenkins <jenkins@myserver.com>"
698
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300699Slack plugin configuration:
Jakub Josefa6d4c832017-01-19 14:06:12 +0100700
701.. code-block:: yaml
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400702
Jakub Josefa6d4c832017-01-19 14:06:12 +0100703 jenkins:
704 client:
705 slack:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100706 team_domain: example.com
707 token: slack-token
708 room: slack-room
Jakub Josef6e0cda92017-02-14 18:01:58 +0100709 token_credential_id: cred_id
Ales Komarekffe8bb22017-02-09 11:10:16 +0100710 send_as: Some slack user
Jakub Josefa6d4c832017-01-19 14:06:12 +0100711
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300712Pipeline global libraries setup:
Jakub Josef6e0cda92017-02-14 18:01:58 +0100713
714.. code-block:: yaml
715
716 jenkins:
717 client:
718 lib:
719 my-pipeline-library:
720 enabled: true
721 url: https://path-to-my-library
722 credential_id: github
723 branch: master # optional, default master
724 implicit: true # optional default true
Jakub Josefd8e04292016-11-28 18:02:27 +0100725
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300726Artifactory server enforcing:
Jakub Josef01940252017-05-10 14:01:22 +0200727
728.. code-block:: yaml
729
730 jenkins:
731 client:
732 artifactory:
733 my-artifactory-server:
734 enabled: true
735 url: https://path-to-my-library
736 credential_id: github
737
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300738Jenkins Global env properties enforcing:
Jakub Josef184ee1c2017-11-29 16:03:09 +0100739
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400740.. code-block:: yaml
Jakub Josef184ee1c2017-11-29 16:03:09 +0100741
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400742 jenkins:
743 client:
744 globalenvprop:
745 OFFLINE_DEPLOYMENT:
746 enabled: true
747 name: "OFFLINE_DEPLOYMENT" # optional, default using dict key
748 value: "true"
Jakub Josef184ee1c2017-11-29 16:03:09 +0100749
Dmitry Burmistrova3f2c132018-04-10 16:24:25 +0400750Throttle categories management from client (requires
751`Throttle Concurrent Builds <https://plugins.jenkins.io/throttle-concurrents>`_
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300752plugin):
Dmitry Burmistrova3f2c132018-04-10 16:24:25 +0400753
754.. code-block:: yaml
755
756 jenkins:
757 client:
758 throttle_category:
759 'My First Category':
760 max_total: 2
761 max_per_node: 1
762 'My Second Category':
763 max_total: 5
764 max_per_node: 2
765 max_per_label:
766 'node_label_1': 1
767 'node_label_2': 2
768 'My Category To Remove:
769 enabled: false
770
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400771Jira sites management from client (requires
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300772`JIRA <https://plugins.jenkins.io/jira>`_ plugin):
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400773
774.. code-block:: yaml
775
776 # Remove all sites
777 jenkins:
778 client:
779 jira:
780 enabled: False
781
782.. code-block:: yaml
783
784 jenkins:
785 client:
786 jira:
787 sites:
788 'http://my.jira.site/':
789 link_url: 'http://alternative.link/'
790 http_auth: false
791 use_wiki_notation: false
792 record_scm: false
793 disable_changelog: false
794 issue_pattern: ''
795 any_build_result: false
796 user: 'username'
797 password: 'passwd'
798 conn_timeout: 10
799 visible_for_group: ''
800 visible_for_project: ''
801 timestamps: false
802 timestamp_format: ''
Sergey Otpuschennikov74ea2682018-05-21 16:35:36 +0400803
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300804Gerrit trigger plugin configuration:
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400805
806.. code-block:: yaml
807
808 jenkins:
809 client:
810 gerrit:
811 server1:
812 host: "gerrit.domain.local"
813 port: 29418
814 username: "jenkins"
815 email: "jenkins@domain.local"
816 auth_key_file: "/var/jenkins_home/.ssh/id_rsa"
817 frontendURL: "https://gerrit.domain.local"
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +0400818 build_current_patches_only: true
819 abort_new_patchsets: false
820 abort_manual_patchsets: false
821 abort_same_topic: false
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400822 authkey: |
823 SOMESSHKEY
824 server2:
825 host: "gerrit2.domain.local"
826 port: 29418
827 username: "jenkins"
828 email: "jenkins@domain.local"
829 auth_key_file: "/var/jenkins_home/.ssh/id_rsa"
830 frontendURL: "https://gerrit2.domain.local"
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +0400831 build_current_patches_only: true
832 abort_new_patchsets: false
833 abort_manual_patchsets: false
834 abort_same_topic: false
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400835 authkey: |
836 SOMESSHKEY
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400837
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300838CSRF Protection configuration:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400839
840.. code-block:: yaml
841
842 jenkins:
843 client:
844 security:
845 csrf:
846 enabled: true
847 proxy_compat: false
848
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300849Agent to Master Access Control:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400850
851.. code-block:: yaml
852
853 jenkins:
854 client:
855 security:
856 agent2master:
857 enabled: true
858 whitelisted: ''
859 file_path_rules: ''
860
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300861Content Security Policy configuration:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400862
863.. code-block:: yaml
864
865 jenkins:
866 client:
867 security:
868 csp: "sandbox; default-src 'none'; img-src 'self'; style-src 'self';"
869
Ales Komarek4c0bab12016-01-22 12:10:50 +0100870Usage
871=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200872
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300873#. Generate password hash:
Ales Komarek4c0bab12016-01-22 12:10:50 +0100874
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300875 .. code-block:: bash
Ales Komarek4c0bab12016-01-22 12:10:50 +0100876
877 echo -n "salt{plainpassword}" | openssl dgst -sha256
878
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300879#. Place in the configuration ``salt:hashpassword``.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200880
Ales Komarekffe8bb22017-02-09 11:10:16 +0100881
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300882Read more
883=========
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200884
885* https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins