Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 1 | =============== |
| 2 | Jenkins formula |
| 3 | =============== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 4 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 5 | Jenkins CI is an open source automation server written in Java. Jenkins |
| 6 | helps to automate the non-human part of software development process, with |
Dan Alvizu | 5d9336b | 2018-01-15 14:43:51 -0700 | [diff] [blame] | 7 | continuous integration and facilitating technical aspects of continuous delivery. |
| 8 | |
| 9 | (*Source*: `Wikipedia <https://en.wikipedia.org/wiki/Jenkins_(software)>`_ ) |
| 10 | |
| 11 | More information can be found at `<https://jenkins.io/>`_ |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 12 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 13 | Setup jenkins client, works with Salt 2016.3+, supports pipeline workflow |
| 14 | projects only now. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 15 | |
Dan Alvizu | 5d9336b | 2018-01-15 14:43:51 -0700 | [diff] [blame] | 16 | Dependencies |
| 17 | ============== |
| 18 | |
| 19 | To install on Ubuntu, you will need to add the jenkins debian repository to the target |
| 20 | server. You can do this with the `salt-formula-linux formula <https://github.com/salt-formulas/salt-formula-linux>`_ , |
| 21 | with 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 | |
| 34 | This state will need to be applied *before* the jenkins state. |
| 35 | |
| 36 | Using this formula |
| 37 | ================== |
| 38 | |
| 39 | To use this formula, you must install the formula to your salt master as documented |
| 40 | in `saltstack formula docs <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#installation>`_ |
| 41 | |
| 42 | This formula is driven by pillar data, and can be used to install either a Jenkins Master |
| 43 | or Client. See pillar data below for examples. |
| 44 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 45 | |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 46 | Sample pillars |
| 47 | ============== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 48 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 49 | Master role |
| 50 | ----------- |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 51 | |
| 52 | Simple master with reverse proxy |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 53 | |
| 54 | .. code-block:: yaml |
| 55 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 56 | nginx: |
| 57 | server: |
| 58 | site: |
| 59 | jenkins: |
| 60 | enabled: true |
| 61 | type: nginx_proxy |
| 62 | name: jenkins |
| 63 | proxy: |
| 64 | host: 127.0.0.1 |
| 65 | port: 8080 |
| 66 | protocol: http |
| 67 | host: |
| 68 | name: jenkins.example.com |
| 69 | port: 80 |
| 70 | jenkins: |
| 71 | master: |
| 72 | mode: EXCLUSIVE |
Alexander Evseev | 2c494d7 | 2018-08-01 11:52:18 +0200 | [diff] [blame^] | 73 | java_args: -Xms256m -Xmx1g |
Filip Pytloun | 52b9c2c | 2016-01-28 13:45:57 +0100 | [diff] [blame] | 74 | # Do not manage config.xml from Salt, use UI instead |
| 75 | no_config: true |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 76 | slaves: |
| 77 | - name: slave01 |
| 78 | label: pbuilder |
| 79 | executors: 2 |
| 80 | - name: slave02 |
| 81 | label: image_builder |
| 82 | mode: EXCLUSIVE |
| 83 | executors: 2 |
| 84 | views: |
| 85 | - name: "Package builds" |
| 86 | regex: "debian-build-.*" |
| 87 | - name: "Contrail builds" |
| 88 | regex: "contrail-build-.*" |
| 89 | - name: "Aptly" |
| 90 | regex: "aptly-.*" |
| 91 | plugins: |
| 92 | - name: slack |
| 93 | - name: extended-choice-parameter |
| 94 | - name: rebuild |
| 95 | - name: test-stability |
| 96 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 97 | Jenkins master with experimental plugin source support |
Ales Komarek | af967ee | 2016-08-31 19:38:50 +0200 | [diff] [blame] | 98 | |
| 99 | .. code-block:: yaml |
| 100 | |
| 101 | jenkins: |
| 102 | master: |
| 103 | enabled: true |
| 104 | update_site_url: 'http://updates.jenkins-ci.org/experimental/update-center.json' |
| 105 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 106 | SMTP server settings |
Ales Komarek | af967ee | 2016-08-31 19:38:50 +0200 | [diff] [blame] | 107 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 108 | .. code-block:: yaml |
| 109 | |
| 110 | jenkins: |
| 111 | master: |
| 112 | email: |
| 113 | engine: "smtp" |
| 114 | host: "smtp.domain.com" |
| 115 | user: "user@domain.cz" |
| 116 | password: "smtp-password" |
| 117 | port: 25 |
| 118 | |
Jakub Josef | bf0b73e | 2017-03-22 14:32:45 +0100 | [diff] [blame] | 119 | Script approvals from client |
| 120 | |
| 121 | .. code-block:: yaml |
| 122 | |
| 123 | jenkins: |
| 124 | client: |
| 125 | approved_scripts: |
| 126 | - method groovy.json.JsonSlurperClassic parseText java.lang.String |
| 127 | |
| 128 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 129 | Script approvals |
| 130 | |
| 131 | .. code-block:: yaml |
| 132 | |
| 133 | jenkins: |
| 134 | master: |
| 135 | approved_scripts: |
| 136 | - method groovy.json.JsonSlurperClassic parseText java.lang.String |
| 137 | |
| 138 | User enforcement |
| 139 | |
| 140 | .. code-block:: yaml |
| 141 | |
| 142 | jenkins: |
| 143 | master: |
| 144 | user: |
| 145 | admin: |
| 146 | api_token: xxxxxxxxxx |
| 147 | password: admin_password |
| 148 | email: admin@domain.com |
| 149 | user01: |
| 150 | api_token: xxxxxxxxxx |
| 151 | password: user_password |
| 152 | email: user01@domain.com |
| 153 | |
| 154 | |
| 155 | Agent (slave) role |
| 156 | ------------------ |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 157 | |
| 158 | .. code-block:: yaml |
| 159 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 160 | jenkins: |
| 161 | slave: |
| 162 | master: |
| 163 | host: jenkins.example.com |
| 164 | port: 80 |
Michael KutĂ˝ | 37a3595 | 2016-06-10 23:51:36 +0200 | [diff] [blame] | 165 | protocol: http |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 166 | 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 Komarek | af967ee | 2016-08-31 19:38:50 +0200 | [diff] [blame] | 177 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 178 | |
| 179 | Client role |
| 180 | ----------- |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 181 | |
| 182 | Simple client with workflow job definition |
| 183 | |
| 184 | .. code-block:: yaml |
| 185 | |
| 186 | jenkins: |
| 187 | client: |
| 188 | master: |
| 189 | host: jenkins.example.com |
| 190 | port: 80 |
| 191 | protocol: http |
| 192 | job: |
| 193 | jobname: |
| 194 | type: workflow |
| 195 | param: |
| 196 | bool_param: |
| 197 | type: boolean |
| 198 | description: true/false |
| 199 | default: true |
| 200 | string_param: |
| 201 | type: string |
| 202 | description: 1 liner |
| 203 | default: default_string |
| 204 | text_param: |
| 205 | type: text |
| 206 | description: multi-liner |
| 207 | default: default_text |
Filip Pytloun | ebd4d17 | 2016-09-01 14:23:20 +0200 | [diff] [blame] | 208 | jobname_scm: |
| 209 | type: workflow-scm |
| 210 | concurrent: false |
| 211 | scm: |
| 212 | type: git |
| 213 | url: https://github.com/jenkinsci/docker.git |
| 214 | branch: master |
| 215 | script: Jenkinsfile |
| 216 | github: |
| 217 | url: https://github.com/jenkinsci/docker |
| 218 | name: "Jenkins Docker Image" |
| 219 | trigger: |
Tomáš Kukrál | a9cf2c6 | 2017-03-04 11:25:20 +0100 | [diff] [blame] | 220 | timer: |
| 221 | spec: "H H * * *" |
Filip Pytloun | ebd4d17 | 2016-09-01 14:23:20 +0200 | [diff] [blame] | 222 | github: |
| 223 | pollscm: |
| 224 | spec: "H/15 * * * *" |
| 225 | reverse: |
| 226 | projects: |
| 227 | - test1 |
| 228 | - test2 |
| 229 | state: SUCCESS |
| 230 | param: |
| 231 | bool_param: |
| 232 | type: boolean |
| 233 | description: true/false |
| 234 | default: true |
| 235 | string_param: |
| 236 | type: string |
| 237 | description: 1 liner |
| 238 | default: default_string |
| 239 | text_param: |
| 240 | type: text |
| 241 | description: multi-liner |
| 242 | default: default_text |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 243 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 244 | Inline Groovy scripts |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 245 | |
| 246 | .. code-block:: yaml |
| 247 | |
| 248 | jenkins: |
| 249 | client: |
| 250 | job: |
| 251 | test_workflow_jenkins_simple: |
| 252 | type: workflow |
| 253 | display_name: Test jenkins simple workflow |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 254 | script: |
| 255 | content: | |
| 256 | node { |
| 257 | stage 'Stage 1' |
| 258 | echo 'Hello World 1' |
| 259 | stage 'Stage 2' |
| 260 | echo 'Hello World 2' |
| 261 | } |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 262 | test_workflow_jenkins_input: |
| 263 | type: workflow |
| 264 | display_name: Test jenkins workflow inputs |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 265 | script: |
| 266 | content: | |
| 267 | node { |
| 268 | stage 'Enter string' |
| 269 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 270 | string(defaultValue: 'default', description: 'Enter a string.', name: 'string'), |
| 271 | ] |
| 272 | stage 'Enter boolean' |
| 273 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 274 | booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'), |
| 275 | ] |
| 276 | stage 'Enter text' |
| 277 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 278 | text(defaultValue: '', description: 'Enter multiline', name: 'Multiline') |
| 279 | ] |
| 280 | } |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 281 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 282 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 283 | GIT controlled groovy scripts |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 284 | |
| 285 | .. code-block:: yaml |
| 286 | |
| 287 | jenkins: |
| 288 | client: |
| 289 | source: |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 290 | base: |
| 291 | engine: git |
| 292 | address: repo_url |
| 293 | branch: branch |
| 294 | domain: |
| 295 | engine: git |
| 296 | address: domain_url |
| 297 | branch: branch |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 298 | job: |
| 299 | test_workflow_jenkins_simple: |
| 300 | type: workflow |
| 301 | display_name: Test jenkins simple workflow |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 302 | param: |
| 303 | bool_param: |
| 304 | type: boolean |
| 305 | description: true/false |
| 306 | default: true |
| 307 | script: |
| 308 | repository: base |
| 309 | file: workflows/test_workflow_jenkins_simple.groovy |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 310 | test_workflow_jenkins_input: |
| 311 | type: workflow |
| 312 | display_name: Test jenkins workflow inputs |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 313 | script: |
| 314 | repository: domain |
| 315 | file: workflows/test_workflow_jenkins_input.groovy |
| 316 | test_workflow_jenkins_input_jenkinsfile: |
| 317 | type: workflow |
| 318 | display_name: Test jenkins workflow inputs (jenknisfile) |
| 319 | script: |
| 320 | repository: domain |
| 321 | file: workflows/test_workflow_jenkins_input/Jenkinsfile |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 322 | |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 323 | GIT controlled groovy script with shared libraries |
| 324 | |
| 325 | .. code-block:: yaml |
| 326 | |
| 327 | jenkins: |
| 328 | client: |
| 329 | source: |
| 330 | base: |
| 331 | engine: git |
| 332 | address: repo_url |
| 333 | branch: branch |
| 334 | domain: |
| 335 | engine: git |
| 336 | address: domain_url |
| 337 | branch: branch |
| 338 | job: |
| 339 | test_workflow_jenkins_simple: |
| 340 | type: workflow |
| 341 | display_name: Test jenkins simple workflow |
| 342 | param: |
| 343 | bool_param: |
| 344 | type: boolean |
| 345 | description: true/false |
| 346 | default: true |
| 347 | script: |
| 348 | repository: base |
| 349 | file: workflows/test_workflow_jenkins_simple.groovy |
| 350 | libs: |
| 351 | - repository: base |
| 352 | file: macros/cookiecutter.groovy |
| 353 | - repository: base |
| 354 | file: macros/git.groovy |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 355 | |
Jakub Josef | 120714d | 2017-02-09 16:29:18 +0100 | [diff] [blame] | 356 | Setting job max builds to keep (amount of last builds stored on Jenkins master) |
| 357 | |
| 358 | .. code-block:: yaml |
| 359 | |
| 360 | jenkins: |
| 361 | client: |
| 362 | job: |
| 363 | my-amazing-job: |
| 364 | type: workflow |
| 365 | discard: |
| 366 | build: |
| 367 | keep_num: 5 |
| 368 | keep_days: 5 |
| 369 | artifact: |
| 370 | keep_num: 6 |
| 371 | keep_days: 6 |
| 372 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 373 | |
| 374 | Using job templates in similar way as in jjb. For now just 1 defined param is |
| 375 | supported. |
| 376 | |
| 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 | |
| 400 | Interpolating parameters for job templates. |
| 401 | |
Filip Pytloun | 83129fc | 2017-02-23 10:07:32 +0100 | [diff] [blame] | 402 | .. code-block:: yaml |
| 403 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 404 | _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 | |
Filip Pytloun | 83129fc | 2017-02-23 10:07:32 +0100 | [diff] [blame] | 420 | Or simply define multiple jobs and it's parameters to replace from template: |
| 421 | |
| 422 | .. code-block:: yaml |
| 423 | |
| 424 | jenkins: |
| 425 | client: |
| 426 | job_template: |
| 427 | test_workflow_template: |
| 428 | name: test-{{name}}-{{myparam}} |
| 429 | template: |
| 430 | ... |
| 431 | jobs: |
| 432 | - name: firstjob |
| 433 | myparam: dummy |
| 434 | - name: secondjob |
| 435 | myparam: dummyaswell |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 436 | |
Jakub Josef | 2a7739b | 2017-01-24 18:33:44 +0100 | [diff] [blame] | 437 | Purging undefined jobs from Jenkins |
| 438 | |
| 439 | .. code-block:: yaml |
| 440 | |
| 441 | jenkins: |
| 442 | client: |
| 443 | purge_jobs: true |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 444 | job: |
| 445 | my-amazing-job: |
| 446 | type: workflow |
Jakub Josef | 2a7739b | 2017-01-24 18:33:44 +0100 | [diff] [blame] | 447 | |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 448 | Plugins management from client |
| 449 | |
| 450 | .. code-block:: yaml |
| 451 | |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 452 | |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 453 | jenkins: |
| 454 | client: |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 455 | plugin_remove_unwanted: false |
| 456 | plugin_force_remove: false |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 457 | plugin: |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 458 | plugin1: 1.2.3 |
| 459 | plugin2: |
| 460 | plugin3: {} |
| 461 | plugin4: |
| 462 | version: 3.2.1 |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 463 | enabled: false |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 464 | plugin5: absent |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 465 | |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 466 | Adding plugin params to job |
| 467 | |
| 468 | .. code-block:: yaml |
| 469 | |
| 470 | |
| 471 | jenkins: |
| 472 | client: |
| 473 | job: |
| 474 | my_plugin_parametrized_job: |
| 475 | plugin_properties: |
| 476 | throttleconcurrents: |
| 477 | enabled: True |
| 478 | max_concurrent_per_node: 3 |
Vasyl Saienko | 661acf4 | 2018-01-18 10:37:07 +0200 | [diff] [blame] | 479 | max_concurrent_total: 1 |
| 480 | throttle_option: category #one of project (default or category) |
| 481 | categories: |
| 482 | - my_throuttle_category |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 483 | plugin: |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 484 | throttle-concurrents: |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 485 | |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 486 | LDAP configuration (depends on LDAP plugin) |
| 487 | |
| 488 | .. code-block:: yaml |
| 489 | |
| 490 | jenkins: |
| 491 | client: |
| 492 | security: |
| 493 | ldap: |
| 494 | server: 1.2.3.4 |
| 495 | root_dn: dc=foo,dc=com |
| 496 | user_search_base: cn=users,cn=accounts |
| 497 | manager_dn: "" |
| 498 | manager_password: password |
| 499 | user_search: "" |
| 500 | group_search_base: "" |
| 501 | inhibit_infer_root_dn: false |
| 502 | |
| 503 | |
| 504 | Matrix configuration (depends on auth-matrix plugin) |
| 505 | |
| 506 | .. code-block:: yaml |
| 507 | |
| 508 | jenkins: |
| 509 | client: |
| 510 | security: |
| 511 | matrix: |
Jakub Josef | 0ee470e | 2017-01-17 11:46:58 +0100 | [diff] [blame] | 512 | # set true for use ProjectMatrixAuthStrategy instead of GlobalMatrixAuthStrategy |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 513 | project_based: false |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 514 | 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 Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 525 | MasterComputer: |
| 526 | BUILD: |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 527 | - user3 |
| 528 | # jobs permissions |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 529 | hudson: |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 530 | model: |
| 531 | Item: |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 532 | BUILD: |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 533 | - user4 |
| 534 | |
| 535 | `Common matrix strategies <https://github.com/arbabnazar/configuration/blob/c08a5eaf4e04a68d2481375502a926517097b253/playbooks/roles/tools_jenkins/templates/projectBasedMatrixSecurity.groovy.j2>`_ |
| 536 | |
Jakub Josef | 7bb17ab | 2017-01-12 14:52:53 +0100 | [diff] [blame] | 537 | Views enforcing from client |
| 538 | |
| 539 | .. code-block:: yaml |
| 540 | |
| 541 | jenkins: |
| 542 | client: |
| 543 | view: |
| 544 | my-list-view: |
| 545 | enabled: true |
| 546 | type: ListView |
Jakub Josef | 7d9fce3 | 2017-03-24 16:46:56 +0100 | [diff] [blame] | 547 | include_regex: ".*" |
Jakub Josef | 7bb17ab | 2017-01-12 14:52:53 +0100 | [diff] [blame] | 548 | my-view: |
| 549 | # set false to disable |
| 550 | enabled: true |
| 551 | type: MyView |
| 552 | |
| 553 | View specific params: |
| 554 | |
Jakub Josef | 7d9fce3 | 2017-03-24 16:46:56 +0100 | [diff] [blame] | 555 | - include_regex for ListView and CategorizedJobsView |
| 556 | - categories for CategorizedJobsView |
| 557 | |
| 558 | Categorized views |
| 559 | |
| 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 Josef | 7bb17ab | 2017-01-12 14:52:53 +0100 | [diff] [blame] | 574 | |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 575 | |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 576 | Credentials enforcing from client |
| 577 | |
| 578 | .. code-block:: yaml |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 579 | |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 580 | jenkins: |
| 581 | client: |
| 582 | credential: |
| 583 | cred_first: |
| 584 | username: admin |
| 585 | password: password |
| 586 | cred_second: |
| 587 | username: salt |
| 588 | password: password |
| 589 | cred_with_key: |
| 590 | username: admin |
| 591 | key: SOMESSHKEY |
Sergey Otpuschennikov | 1dd7799 | 2018-06-27 11:11:07 +0400 | [diff] [blame] | 592 | cred_with_text_secret: |
| 593 | secret: SOMETEXTSECRET |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 594 | |
| 595 | Users enforcing from client |
| 596 | |
| 597 | .. code-block:: yaml |
| 598 | |
| 599 | jenkins: |
| 600 | client: |
| 601 | user: |
| 602 | admin: |
| 603 | password: admin_password |
| 604 | admin: true |
| 605 | user01: |
| 606 | password: user_password |
| 607 | |
| 608 | Node enforcing from client using JNLP launcher |
| 609 | |
| 610 | .. code-block:: yaml |
| 611 | |
| 612 | jenkins: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 613 | client: |
| 614 | node: |
| 615 | node01: |
| 616 | remote_home: /remote/home/path |
| 617 | desc: node-description |
| 618 | num_executors: 1 |
| 619 | node_mode: Normal |
| 620 | ret_strategy: Always |
| 621 | labels: |
| 622 | - example |
| 623 | - label |
| 624 | launcher: |
| 625 | type: jnlp |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 626 | |
| 627 | Node enforcing from client using SSH launcher |
| 628 | |
| 629 | .. code-block:: yaml |
| 630 | |
| 631 | jenkins: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 632 | client: |
| 633 | node: |
| 634 | node01: |
| 635 | remote_home: /remote/home/path |
| 636 | desc: node-description |
| 637 | num_executors: 1 |
| 638 | node_mode: Normal |
| 639 | ret_strategy: Always |
| 640 | labels: |
| 641 | - example |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 642 | - label |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 643 | launcher: |
| 644 | type: ssh |
| 645 | host: test-launcher |
| 646 | port: 22 |
| 647 | username: launcher-user |
| 648 | password: launcher-pass |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 649 | |
Jakub Josef | 1bb7f44 | 2017-05-26 17:02:56 +0200 | [diff] [blame] | 650 | Configure Jenkins master |
| 651 | |
| 652 | .. code-block:: yaml |
| 653 | |
| 654 | jenkins: |
| 655 | client: |
| 656 | node: |
| 657 | master: |
| 658 | num_executors: 1 |
| 659 | node_mode: Normal # or Exclusive |
| 660 | labels: |
| 661 | - example |
| 662 | - label |
| 663 | |
| 664 | |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 665 | Setting node labels |
| 666 | |
| 667 | .. code-block:: yaml |
| 668 | |
| 669 | jenkins: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 670 | client: |
| 671 | label: |
| 672 | node-name: |
| 673 | lbl_text: label-offline |
| 674 | append: false # set true for label append instead of replace |
Jakub Josef | d8e0429 | 2016-11-28 18:02:27 +0100 | [diff] [blame] | 675 | |
Jakub Josef | 60cc9d2 | 2017-01-18 12:02:14 +0100 | [diff] [blame] | 676 | SMTP server settings from client |
| 677 | |
| 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 | |
Jakub Josef | dfb288c | 2017-04-27 17:29:00 +0200 | [diff] [blame] | 690 | Jenkins admin user email enforcement from client |
| 691 | |
| 692 | .. code-block:: yaml |
| 693 | |
| 694 | jenkins: |
| 695 | client: |
| 696 | smtp: |
| 697 | admin_email: "My Jenkins <jenkins@myserver.com>" |
| 698 | |
| 699 | |
Jakub Josef | a6d4c83 | 2017-01-19 14:06:12 +0100 | [diff] [blame] | 700 | Slack plugin configuration |
| 701 | |
| 702 | .. code-block:: yaml |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 703 | |
Jakub Josef | a6d4c83 | 2017-01-19 14:06:12 +0100 | [diff] [blame] | 704 | jenkins: |
| 705 | client: |
| 706 | slack: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 707 | team_domain: example.com |
| 708 | token: slack-token |
| 709 | room: slack-room |
Jakub Josef | 6e0cda9 | 2017-02-14 18:01:58 +0100 | [diff] [blame] | 710 | token_credential_id: cred_id |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 711 | send_as: Some slack user |
Jakub Josef | a6d4c83 | 2017-01-19 14:06:12 +0100 | [diff] [blame] | 712 | |
Jakub Josef | 6e0cda9 | 2017-02-14 18:01:58 +0100 | [diff] [blame] | 713 | Pipeline global libraries setup |
| 714 | |
| 715 | .. code-block:: yaml |
| 716 | |
| 717 | jenkins: |
| 718 | client: |
| 719 | lib: |
| 720 | my-pipeline-library: |
| 721 | enabled: true |
| 722 | url: https://path-to-my-library |
| 723 | credential_id: github |
| 724 | branch: master # optional, default master |
| 725 | implicit: true # optional default true |
Jakub Josef | d8e0429 | 2016-11-28 18:02:27 +0100 | [diff] [blame] | 726 | |
Jakub Josef | 0194025 | 2017-05-10 14:01:22 +0200 | [diff] [blame] | 727 | Artifactory server enforcing |
| 728 | |
| 729 | .. code-block:: yaml |
| 730 | |
| 731 | jenkins: |
| 732 | client: |
| 733 | artifactory: |
| 734 | my-artifactory-server: |
| 735 | enabled: true |
| 736 | url: https://path-to-my-library |
| 737 | credential_id: github |
| 738 | |
Dmitry Burmistrov | a3f2c13 | 2018-04-10 16:24:25 +0400 | [diff] [blame] | 739 | Jenkins Global env properties enforcing |
Jakub Josef | 184ee1c | 2017-11-29 16:03:09 +0100 | [diff] [blame] | 740 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 741 | .. code-block:: yaml |
Jakub Josef | 184ee1c | 2017-11-29 16:03:09 +0100 | [diff] [blame] | 742 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 743 | jenkins: |
| 744 | client: |
| 745 | globalenvprop: |
| 746 | OFFLINE_DEPLOYMENT: |
| 747 | enabled: true |
| 748 | name: "OFFLINE_DEPLOYMENT" # optional, default using dict key |
| 749 | value: "true" |
Jakub Josef | 184ee1c | 2017-11-29 16:03:09 +0100 | [diff] [blame] | 750 | |
Dmitry Burmistrov | a3f2c13 | 2018-04-10 16:24:25 +0400 | [diff] [blame] | 751 | Throttle categories management from client (requires |
| 752 | `Throttle Concurrent Builds <https://plugins.jenkins.io/throttle-concurrents>`_ |
| 753 | plugin) |
| 754 | |
| 755 | .. code-block:: yaml |
| 756 | |
| 757 | jenkins: |
| 758 | client: |
| 759 | throttle_category: |
| 760 | 'My First Category': |
| 761 | max_total: 2 |
| 762 | max_per_node: 1 |
| 763 | 'My Second Category': |
| 764 | max_total: 5 |
| 765 | max_per_node: 2 |
| 766 | max_per_label: |
| 767 | 'node_label_1': 1 |
| 768 | 'node_label_2': 2 |
| 769 | 'My Category To Remove: |
| 770 | enabled: false |
| 771 | |
Dmitry Burmistrov | 429b8ec | 2018-04-25 17:13:48 +0400 | [diff] [blame] | 772 | Jira sites management from client (requires |
| 773 | `JIRA <https://plugins.jenkins.io/jira>`_ plugin) |
| 774 | |
| 775 | .. code-block:: yaml |
| 776 | |
| 777 | # Remove all sites |
| 778 | jenkins: |
| 779 | client: |
| 780 | jira: |
| 781 | enabled: False |
| 782 | |
| 783 | .. code-block:: yaml |
| 784 | |
| 785 | jenkins: |
| 786 | client: |
| 787 | jira: |
| 788 | sites: |
| 789 | 'http://my.jira.site/': |
| 790 | link_url: 'http://alternative.link/' |
| 791 | http_auth: false |
| 792 | use_wiki_notation: false |
| 793 | record_scm: false |
| 794 | disable_changelog: false |
| 795 | issue_pattern: '' |
| 796 | any_build_result: false |
| 797 | user: 'username' |
| 798 | password: 'passwd' |
| 799 | conn_timeout: 10 |
| 800 | visible_for_group: '' |
| 801 | visible_for_project: '' |
| 802 | timestamps: false |
| 803 | timestamp_format: '' |
Sergey Otpuschennikov | 74ea268 | 2018-05-21 16:35:36 +0400 | [diff] [blame] | 804 | |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 805 | Gerrit trigger plugin configuration |
| 806 | |
| 807 | .. code-block:: yaml |
| 808 | |
| 809 | jenkins: |
| 810 | client: |
| 811 | gerrit: |
| 812 | server1: |
| 813 | host: "gerrit.domain.local" |
| 814 | port: 29418 |
| 815 | username: "jenkins" |
| 816 | email: "jenkins@domain.local" |
| 817 | auth_key_file: "/var/jenkins_home/.ssh/id_rsa" |
| 818 | frontendURL: "https://gerrit.domain.local" |
Sergey Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 819 | build_current_patches_only: true |
| 820 | abort_new_patchsets: false |
| 821 | abort_manual_patchsets: false |
| 822 | abort_same_topic: false |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 823 | authkey: | |
| 824 | SOMESSHKEY |
| 825 | server2: |
| 826 | host: "gerrit2.domain.local" |
| 827 | port: 29418 |
| 828 | username: "jenkins" |
| 829 | email: "jenkins@domain.local" |
| 830 | auth_key_file: "/var/jenkins_home/.ssh/id_rsa" |
| 831 | frontendURL: "https://gerrit2.domain.local" |
Sergey Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 832 | build_current_patches_only: true |
| 833 | abort_new_patchsets: false |
| 834 | abort_manual_patchsets: false |
| 835 | abort_same_topic: false |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 836 | authkey: | |
| 837 | SOMESSHKEY |
Dmitry Burmistrov | 429b8ec | 2018-04-25 17:13:48 +0400 | [diff] [blame] | 838 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 839 | CSRF Protection configuration |
| 840 | |
| 841 | .. code-block:: yaml |
| 842 | |
| 843 | jenkins: |
| 844 | client: |
| 845 | security: |
| 846 | csrf: |
| 847 | enabled: true |
| 848 | proxy_compat: false |
| 849 | |
| 850 | |
| 851 | Agent to Master Access Control |
| 852 | |
| 853 | .. code-block:: yaml |
| 854 | |
| 855 | jenkins: |
| 856 | client: |
| 857 | security: |
| 858 | agent2master: |
| 859 | enabled: true |
| 860 | whitelisted: '' |
| 861 | file_path_rules: '' |
| 862 | |
| 863 | Content Security Policy configuration |
| 864 | |
| 865 | .. code-block:: yaml |
| 866 | |
| 867 | jenkins: |
| 868 | client: |
| 869 | security: |
| 870 | csp: "sandbox; default-src 'none'; img-src 'self'; style-src 'self';" |
| 871 | |
| 872 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 873 | Usage |
| 874 | ===== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 875 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 876 | Generate password hash: |
| 877 | |
| 878 | .. code-block:: bash |
| 879 | |
| 880 | echo -n "salt{plainpassword}" | openssl dgst -sha256 |
| 881 | |
| 882 | Place in the configuration ``salt:hashpassword``. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 883 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 884 | |
| 885 | External links |
| 886 | ============== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 887 | |
| 888 | * https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins |
Filip Pytloun | adf72fa | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 889 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 890 | |
Filip Pytloun | adf72fa | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 891 | Documentation and Bugs |
| 892 | ====================== |
| 893 | |
| 894 | To learn how to install and update salt-formulas, consult the documentation |
| 895 | available online at: |
| 896 | |
| 897 | http://salt-formulas.readthedocs.io/ |
| 898 | |
| 899 | In the unfortunate event that bugs are discovered, they should be reported to |
| 900 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 901 | formula: |
| 902 | |
| 903 | https://github.com/salt-formulas/salt-formula-jenkins/issues |
| 904 | |
| 905 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 906 | use Launchpad salt-formulas project: |
| 907 | |
| 908 | https://launchpad.net/salt-formulas |
| 909 | |
| 910 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 911 | |
| 912 | https://launchpad.net/~salt-formulas-users |
| 913 | |
| 914 | Developers wishing to work on the salt-formulas projects should always base |
| 915 | their work on master branch and submit pull request against specific formula. |
| 916 | |
| 917 | https://github.com/salt-formulas/salt-formula-jenkins |
| 918 | |
| 919 | Any questions or feedback is always welcome so feel free to join our IRC |
| 920 | channel: |
| 921 | |
| 922 | #salt-formulas @ irc.freenode.net |