blob: ff3a48afb9276031f457efd0754da7fd7bf14cf1 [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 Berezovskiyf6177312019-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
Vladimir Khlyunev22b44552022-04-22 16:23:07 +0400468Alternative plugin management using version pins (baseline plugin management could not work with some
469modern version labels like "1.12+build.201809061734").
470
471.. code-block:: yaml
472
473 jenkins:
474 client:
475 plugin:
476 alt_update:
477 enabled: True
478 base_url: https://archives.jenkins-ci.org/plugins/
479 jenkins_home_volume_dir: /srv/volumes/jenkins/
480 plugins:
481 ace-editor:
482 source_hash: abc97028893c8a71581a5f559ea48e8e1f1a65164faee96dabfed9e95e9abad2
483 version: '1.1'
484 ant:
485 source_hash: f04961a8a42f1e2ccdf5001d33ae93fdc2b3a5af96f13bddc1d721f1d11a8b4b
486 version: '1.8'
487 apache-httpcomponents-client-4-api:
488 enabled: False
489
490
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300491Adding plugin params to job:
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200492
493.. code-block:: yaml
494
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200495 jenkins:
496 client:
497 job:
498 my_plugin_parametrized_job:
499 plugin_properties:
500 throttleconcurrents:
501 enabled: True
502 max_concurrent_per_node: 3
Vasyl Saienko661acf42018-01-18 10:37:07 +0200503 max_concurrent_total: 1
504 throttle_option: category #one of project (default or category)
505 categories:
506 - my_throuttle_category
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200507 plugin:
Alexander Evseevcd836a12018-07-27 13:02:45 +0200508 throttle-concurrents:
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200509
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300510LDAP configuration (depends on LDAP plugin):
Jakub Josef063a7532017-01-11 15:48:01 +0100511
512.. code-block:: yaml
513
514 jenkins:
515 client:
516 security:
517 ldap:
518 server: 1.2.3.4
519 root_dn: dc=foo,dc=com
520 user_search_base: cn=users,cn=accounts
521 manager_dn: ""
522 manager_password: password
523 user_search: ""
524 group_search_base: ""
525 inhibit_infer_root_dn: false
526
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300527Matrix configuration (depends on auth-matrix plugin):
Jakub Josef063a7532017-01-11 15:48:01 +0100528
529.. code-block:: yaml
530
531 jenkins:
532 client:
533 security:
534 matrix:
Jakub Josef0ee470e2017-01-17 11:46:58 +0100535 # set true for use ProjectMatrixAuthStrategy instead of GlobalMatrixAuthStrategy
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400536 project_based: false
Jakub Josef063a7532017-01-11 15:48:01 +0100537 permissions:
538 Jenkins:
539 # administrator access
540 ADMINISTER:
541 - admin
542 # read access (anonymous too)
543 READ:
544 - anonymous
545 - user1
546 - user2
547 # agents permissions
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400548 MasterComputer:
549 BUILD:
Jakub Josef063a7532017-01-11 15:48:01 +0100550 - user3
551 # jobs permissions
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400552 hudson:
Jakub Josef063a7532017-01-11 15:48:01 +0100553 model:
554 Item:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400555 BUILD:
Jakub Josef063a7532017-01-11 15:48:01 +0100556 - user4
557
558`Common matrix strategies <https://github.com/arbabnazar/configuration/blob/c08a5eaf4e04a68d2481375502a926517097b253/playbooks/roles/tools_jenkins/templates/projectBasedMatrixSecurity.groovy.j2>`_
559
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300560Views enforcing from client:
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100561
562.. code-block:: yaml
563
564 jenkins:
565 client:
566 view:
567 my-list-view:
568 enabled: true
569 type: ListView
Jakub Josef7d9fce32017-03-24 16:46:56 +0100570 include_regex: ".*"
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100571 my-view:
572 # set false to disable
573 enabled: true
574 type: MyView
575
576View specific params:
577
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300578- ``include_regex`` for ``ListView`` and ``CategorizedJobsView``
579- categories for ``CategorizedJobsView``
Jakub Josef7d9fce32017-03-24 16:46:56 +0100580
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300581Categorized views:
Jakub Josef7d9fce32017-03-24 16:46:56 +0100582
583.. code-block:: yaml
584
585 jenkins:
586 client:
587 view:
588 my-categorized-view:
589 enabled: true
590 type: CategorizedJobsView
591 include_regex: ".*"
592 categories:
593 - group_regex: "aptly-.*-nightly-testing"
594 naming_rule: "Nightly -> Testing"
595 - group_regex: "aptly-.*-nightly-production"
596 naming_rule: "Nightly -> Production"
Jakub Josef7bb17ab2017-01-12 14:52:53 +0100597
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300598Credentials enforcing from client:
Jakub Josef123be7a2016-12-12 16:02:36 +0100599
600.. code-block:: yaml
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200601
Jakub Josef123be7a2016-12-12 16:02:36 +0100602 jenkins:
603 client:
604 credential:
605 cred_first:
606 username: admin
607 password: password
608 cred_second:
609 username: salt
610 password: password
611 cred_with_key:
612 username: admin
613 key: SOMESSHKEY
Sergey Otpuschennikov1dd77992018-06-27 11:11:07 +0400614 cred_with_text_secret:
615 secret: SOMETEXTSECRET
Yuriy Taraday2e21e3c2018-02-06 20:17:58 +0400616 cred_with_secret_file:
617 filename: somefile.json
618 content: |
619 { "Hello": "world!" }
Jakub Josef123be7a2016-12-12 16:02:36 +0100620
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300621Users enforcing from client:
Jakub Josef123be7a2016-12-12 16:02:36 +0100622
623.. code-block:: yaml
624
625 jenkins:
626 client:
627 user:
628 admin:
629 password: admin_password
630 admin: true
631 user01:
632 password: user_password
633
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300634Node enforcing from client using JNLP launcher:
Jakub Josef123be7a2016-12-12 16:02:36 +0100635
636.. code-block:: yaml
637
638 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100639 client:
640 node:
641 node01:
642 remote_home: /remote/home/path
643 desc: node-description
644 num_executors: 1
645 node_mode: Normal
646 ret_strategy: Always
647 labels:
648 - example
649 - label
650 launcher:
651 type: jnlp
Jakub Josef123be7a2016-12-12 16:02:36 +0100652
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300653Node enforcing from client using SSH launcher:
Jakub Josef123be7a2016-12-12 16:02:36 +0100654
655.. code-block:: yaml
656
657 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100658 client:
659 node:
660 node01:
661 remote_home: /remote/home/path
662 desc: node-description
663 num_executors: 1
664 node_mode: Normal
665 ret_strategy: Always
666 labels:
667 - example
Vasyl Saienkocb928a82018-01-17 15:21:28 +0200668 - label
Ales Komarekffe8bb22017-02-09 11:10:16 +0100669 launcher:
670 type: ssh
671 host: test-launcher
672 port: 22
673 username: launcher-user
674 password: launcher-pass
Jakub Josef123be7a2016-12-12 16:02:36 +0100675
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300676Configure Jenkins master:
Jakub Josef1bb7f442017-05-26 17:02:56 +0200677
678.. code-block:: yaml
679
680 jenkins:
681 client:
682 node:
683 master:
684 num_executors: 1
685 node_mode: Normal # or Exclusive
686 labels:
687 - example
688 - label
689
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300690Setting node labels:
Jakub Josef123be7a2016-12-12 16:02:36 +0100691
692.. code-block:: yaml
693
694 jenkins:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100695 client:
696 label:
697 node-name:
698 lbl_text: label-offline
699 append: false # set true for label append instead of replace
Jakub Josefd8e04292016-11-28 18:02:27 +0100700
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300701SMTP server settings from client:
Jakub Josef60cc9d22017-01-18 12:02:14 +0100702
703.. code-block:: yaml
704
705 jenkins:
706 client:
707 smtp:
708 host: "smtp.domain.com"
709 username: "user@domain.cz"
710 password: "smtp-password"
711 port: 25
712 ssl: false
713 reply_to: reply_to@address.com
714
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300715Jenkins admin user email enforcement from client:
Jakub Josefdfb288c2017-04-27 17:29:00 +0200716
717.. code-block:: yaml
718
719 jenkins:
720 client:
721 smtp:
722 admin_email: "My Jenkins <jenkins@myserver.com>"
723
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300724Slack plugin configuration:
Jakub Josefa6d4c832017-01-19 14:06:12 +0100725
726.. code-block:: yaml
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400727
Jakub Josefa6d4c832017-01-19 14:06:12 +0100728 jenkins:
729 client:
730 slack:
Ales Komarekffe8bb22017-02-09 11:10:16 +0100731 team_domain: example.com
732 token: slack-token
733 room: slack-room
Jakub Josef6e0cda92017-02-14 18:01:58 +0100734 token_credential_id: cred_id
Ales Komarekffe8bb22017-02-09 11:10:16 +0100735 send_as: Some slack user
Jakub Josefa6d4c832017-01-19 14:06:12 +0100736
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300737Pipeline global libraries setup:
Jakub Josef6e0cda92017-02-14 18:01:58 +0100738
739.. code-block:: yaml
740
741 jenkins:
742 client:
743 lib:
744 my-pipeline-library:
745 enabled: true
746 url: https://path-to-my-library
747 credential_id: github
748 branch: master # optional, default master
749 implicit: true # optional default true
Jakub Josefd8e04292016-11-28 18:02:27 +0100750
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300751Artifactory server enforcing:
Jakub Josef01940252017-05-10 14:01:22 +0200752
753.. code-block:: yaml
754
755 jenkins:
756 client:
757 artifactory:
758 my-artifactory-server:
759 enabled: true
760 url: https://path-to-my-library
761 credential_id: github
762
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300763Jenkins Global env properties enforcing:
Jakub Josef184ee1c2017-11-29 16:03:09 +0100764
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400765.. code-block:: yaml
Jakub Josef184ee1c2017-11-29 16:03:09 +0100766
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400767 jenkins:
768 client:
769 globalenvprop:
770 OFFLINE_DEPLOYMENT:
771 enabled: true
772 name: "OFFLINE_DEPLOYMENT" # optional, default using dict key
773 value: "true"
Jakub Josef184ee1c2017-11-29 16:03:09 +0100774
Dmitry Burmistrova3f2c132018-04-10 16:24:25 +0400775Throttle categories management from client (requires
776`Throttle Concurrent Builds <https://plugins.jenkins.io/throttle-concurrents>`_
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300777plugin):
Dmitry Burmistrova3f2c132018-04-10 16:24:25 +0400778
779.. code-block:: yaml
780
781 jenkins:
782 client:
783 throttle_category:
784 'My First Category':
785 max_total: 2
786 max_per_node: 1
787 'My Second Category':
788 max_total: 5
789 max_per_node: 2
790 max_per_label:
791 'node_label_1': 1
792 'node_label_2': 2
793 'My Category To Remove:
794 enabled: false
795
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400796Jira sites management from client (requires
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300797`JIRA <https://plugins.jenkins.io/jira>`_ plugin):
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400798
799.. code-block:: yaml
800
801 # Remove all sites
802 jenkins:
803 client:
804 jira:
805 enabled: False
806
807.. code-block:: yaml
808
809 jenkins:
810 client:
811 jira:
812 sites:
813 'http://my.jira.site/':
814 link_url: 'http://alternative.link/'
815 http_auth: false
816 use_wiki_notation: false
817 record_scm: false
818 disable_changelog: false
819 issue_pattern: ''
820 any_build_result: false
821 user: 'username'
822 password: 'passwd'
823 conn_timeout: 10
824 visible_for_group: ''
825 visible_for_project: ''
826 timestamps: false
827 timestamp_format: ''
Sergey Otpuschennikov74ea2682018-05-21 16:35:36 +0400828
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300829Gerrit trigger plugin configuration:
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400830
831.. code-block:: yaml
832
833 jenkins:
834 client:
835 gerrit:
836 server1:
837 host: "gerrit.domain.local"
838 port: 29418
839 username: "jenkins"
840 email: "jenkins@domain.local"
841 auth_key_file: "/var/jenkins_home/.ssh/id_rsa"
842 frontendURL: "https://gerrit.domain.local"
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +0400843 build_current_patches_only: true
844 abort_new_patchsets: false
845 abort_manual_patchsets: false
846 abort_same_topic: false
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400847 authkey: |
848 SOMESSHKEY
849 server2:
850 host: "gerrit2.domain.local"
851 port: 29418
852 username: "jenkins"
853 email: "jenkins@domain.local"
854 auth_key_file: "/var/jenkins_home/.ssh/id_rsa"
855 frontendURL: "https://gerrit2.domain.local"
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +0400856 build_current_patches_only: true
857 abort_new_patchsets: false
858 abort_manual_patchsets: false
859 abort_same_topic: false
Sergey Otpuschennikov83996702017-11-23 17:10:57 +0400860 authkey: |
861 SOMESSHKEY
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +0400862
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300863CSRF Protection configuration:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400864
865.. code-block:: yaml
866
867 jenkins:
868 client:
869 security:
870 csrf:
871 enabled: true
872 proxy_compat: false
873
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300874Agent to Master Access Control:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400875
876.. code-block:: yaml
877
878 jenkins:
879 client:
880 security:
881 agent2master:
882 enabled: true
883 whitelisted: ''
884 file_path_rules: ''
885
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300886Content Security Policy configuration:
Dmitry Burmistrov2953edf2018-05-24 11:32:54 +0400887
888.. code-block:: yaml
889
890 jenkins:
891 client:
892 security:
893 csp: "sandbox; default-src 'none'; img-src 'self'; style-src 'self';"
894
Vladimir Khlyunevc51e55a2023-10-11 19:21:07 +0400895Git-client plugin's ssh host key verification strategy:
896
897Allowed settings:
898
899.. code-block:: yaml
900 - noHostKeyVerificationStrategy
901 - knownHostsFileVerificationStrategy
902 - acceptFirstConnectionStrategy
903
904.. code-block:: yaml
905
906 jenkins:
907 client:
908 security:
909 git_ssh_host_key_strategy: "acceptFirstConnectionStrategy"
910
Ales Komarek4c0bab12016-01-22 12:10:50 +0100911Usage
912=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200913
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300914#. Generate password hash:
Ales Komarek4c0bab12016-01-22 12:10:50 +0100915
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300916 .. code-block:: bash
Ales Komarek4c0bab12016-01-22 12:10:50 +0100917
918 echo -n "salt{plainpassword}" | openssl dgst -sha256
919
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300920#. Place in the configuration ``salt:hashpassword``.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200921
Ales Komarekffe8bb22017-02-09 11:10:16 +0100922
OlgaGusarenkof20d94d2018-07-30 18:48:25 +0300923Read more
924=========
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200925
926* https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins