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 |
Alexander Evseev | 1ed23bf | 2018-08-02 12:12:19 +0200 | [diff] [blame^] | 74 | # Do not manage any xml config files via Salt, use UI instead |
| 75 | # Including config.xml and any plugin xml's. |
Filip Pytloun | 52b9c2c | 2016-01-28 13:45:57 +0100 | [diff] [blame] | 76 | no_config: true |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 77 | slaves: |
| 78 | - name: slave01 |
| 79 | label: pbuilder |
| 80 | executors: 2 |
| 81 | - name: slave02 |
| 82 | label: image_builder |
| 83 | mode: EXCLUSIVE |
| 84 | executors: 2 |
| 85 | views: |
| 86 | - name: "Package builds" |
| 87 | regex: "debian-build-.*" |
| 88 | - name: "Contrail builds" |
| 89 | regex: "contrail-build-.*" |
| 90 | - name: "Aptly" |
| 91 | regex: "aptly-.*" |
| 92 | plugins: |
| 93 | - name: slack |
| 94 | - name: extended-choice-parameter |
| 95 | - name: rebuild |
| 96 | - name: test-stability |
| 97 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 98 | Jenkins master with experimental plugin source support |
Ales Komarek | af967ee | 2016-08-31 19:38:50 +0200 | [diff] [blame] | 99 | |
| 100 | .. code-block:: yaml |
| 101 | |
| 102 | jenkins: |
| 103 | master: |
| 104 | enabled: true |
| 105 | update_site_url: 'http://updates.jenkins-ci.org/experimental/update-center.json' |
| 106 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 107 | SMTP server settings |
Ales Komarek | af967ee | 2016-08-31 19:38:50 +0200 | [diff] [blame] | 108 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 109 | .. code-block:: yaml |
| 110 | |
| 111 | jenkins: |
| 112 | master: |
| 113 | email: |
| 114 | engine: "smtp" |
| 115 | host: "smtp.domain.com" |
| 116 | user: "user@domain.cz" |
| 117 | password: "smtp-password" |
| 118 | port: 25 |
| 119 | |
Jakub Josef | bf0b73e | 2017-03-22 14:32:45 +0100 | [diff] [blame] | 120 | Script approvals from client |
| 121 | |
| 122 | .. code-block:: yaml |
| 123 | |
| 124 | jenkins: |
| 125 | client: |
| 126 | approved_scripts: |
| 127 | - method groovy.json.JsonSlurperClassic parseText java.lang.String |
| 128 | |
| 129 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 130 | Script approvals |
| 131 | |
| 132 | .. code-block:: yaml |
| 133 | |
| 134 | jenkins: |
| 135 | master: |
| 136 | approved_scripts: |
| 137 | - method groovy.json.JsonSlurperClassic parseText java.lang.String |
| 138 | |
| 139 | User enforcement |
| 140 | |
| 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 | |
| 155 | |
| 156 | Agent (slave) role |
| 157 | ------------------ |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 158 | |
| 159 | .. code-block:: yaml |
| 160 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 161 | jenkins: |
| 162 | slave: |
| 163 | master: |
| 164 | host: jenkins.example.com |
| 165 | port: 80 |
Michael KutĂ˝ | 37a3595 | 2016-06-10 23:51:36 +0200 | [diff] [blame] | 166 | protocol: http |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 167 | user: |
| 168 | name: jenkins_slave |
| 169 | password: dexiech6AepohthaiHook2iesh7ol5ook4Ov3leid3yek6daid2ooNg3Ee2oKeYo |
| 170 | gpg: |
| 171 | keypair_id: A76882D3 |
| 172 | public_key: | |
| 173 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 174 | ... |
| 175 | private_key: | |
| 176 | -----BEGIN PGP PRIVATE KEY BLOCK----- |
| 177 | ... |
Ales Komarek | af967ee | 2016-08-31 19:38:50 +0200 | [diff] [blame] | 178 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 179 | |
| 180 | Client role |
| 181 | ----------- |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 182 | |
| 183 | Simple client with workflow job definition |
| 184 | |
| 185 | .. code-block:: yaml |
| 186 | |
| 187 | jenkins: |
| 188 | client: |
| 189 | master: |
| 190 | host: jenkins.example.com |
| 191 | port: 80 |
| 192 | protocol: http |
| 193 | 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 Pytloun | ebd4d17 | 2016-09-01 14:23:20 +0200 | [diff] [blame] | 209 | 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ál | a9cf2c6 | 2017-03-04 11:25:20 +0100 | [diff] [blame] | 221 | timer: |
| 222 | spec: "H H * * *" |
Filip Pytloun | ebd4d17 | 2016-09-01 14:23:20 +0200 | [diff] [blame] | 223 | github: |
| 224 | pollscm: |
| 225 | spec: "H/15 * * * *" |
| 226 | reverse: |
| 227 | projects: |
| 228 | - test1 |
| 229 | - test2 |
| 230 | state: SUCCESS |
| 231 | param: |
| 232 | bool_param: |
| 233 | type: boolean |
| 234 | description: true/false |
| 235 | default: true |
| 236 | string_param: |
| 237 | type: string |
| 238 | description: 1 liner |
| 239 | default: default_string |
| 240 | text_param: |
| 241 | type: text |
| 242 | description: multi-liner |
| 243 | default: default_text |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 244 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 245 | Inline Groovy scripts |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 246 | |
| 247 | .. code-block:: yaml |
| 248 | |
| 249 | jenkins: |
| 250 | client: |
| 251 | job: |
| 252 | test_workflow_jenkins_simple: |
| 253 | type: workflow |
| 254 | display_name: Test jenkins simple workflow |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 255 | script: |
| 256 | content: | |
| 257 | node { |
| 258 | stage 'Stage 1' |
| 259 | echo 'Hello World 1' |
| 260 | stage 'Stage 2' |
| 261 | echo 'Hello World 2' |
| 262 | } |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 263 | test_workflow_jenkins_input: |
| 264 | type: workflow |
| 265 | display_name: Test jenkins workflow inputs |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 266 | script: |
| 267 | content: | |
| 268 | node { |
| 269 | stage 'Enter string' |
| 270 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 271 | string(defaultValue: 'default', description: 'Enter a string.', name: 'string'), |
| 272 | ] |
| 273 | stage 'Enter boolean' |
| 274 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 275 | booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'), |
| 276 | ] |
| 277 | stage 'Enter text' |
| 278 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 279 | text(defaultValue: '', description: 'Enter multiline', name: 'Multiline') |
| 280 | ] |
| 281 | } |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 282 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 283 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 284 | GIT controlled groovy scripts |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 285 | |
| 286 | .. code-block:: yaml |
| 287 | |
| 288 | jenkins: |
| 289 | client: |
| 290 | source: |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 291 | base: |
| 292 | engine: git |
| 293 | address: repo_url |
| 294 | branch: branch |
| 295 | domain: |
| 296 | engine: git |
| 297 | address: domain_url |
| 298 | branch: branch |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 299 | job: |
| 300 | test_workflow_jenkins_simple: |
| 301 | type: workflow |
| 302 | display_name: Test jenkins simple workflow |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 303 | 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 Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 311 | test_workflow_jenkins_input: |
| 312 | type: workflow |
| 313 | display_name: Test jenkins workflow inputs |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 314 | 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 Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 323 | |
Ales Komarek | 5b672fd | 2016-08-29 16:05:03 +0200 | [diff] [blame] | 324 | GIT controlled groovy script with shared libraries |
| 325 | |
| 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 Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame] | 356 | |
Jakub Josef | 120714d | 2017-02-09 16:29:18 +0100 | [diff] [blame] | 357 | Setting 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 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 374 | |
| 375 | Using job templates in similar way as in jjb. For now just 1 defined param is |
| 376 | supported. |
| 377 | |
| 378 | .. code-block:: yaml |
| 379 | |
| 380 | jenkins: |
| 381 | client: |
| 382 | job_template: |
| 383 | test_workflow_template: |
| 384 | name: test-{{formula}}-workflow |
| 385 | template: |
| 386 | type: workflow |
| 387 | display_name: Test jenkins {{name}} workflow |
| 388 | param: |
| 389 | repo_param: |
| 390 | type: string |
| 391 | default: repo/{{formula}} |
| 392 | script: |
| 393 | repository: base |
| 394 | file: workflows/test_formula_workflow.groovy |
| 395 | param: |
| 396 | formula: |
| 397 | - aodh |
| 398 | - linux |
| 399 | - openssh |
| 400 | |
| 401 | Interpolating parameters for job templates. |
| 402 | |
Filip Pytloun | 83129fc | 2017-02-23 10:07:32 +0100 | [diff] [blame] | 403 | .. code-block:: yaml |
| 404 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 405 | _param: |
| 406 | salt_formulas: |
| 407 | - aodh |
| 408 | - git |
| 409 | - nova |
| 410 | - xorg |
| 411 | jenkins: |
| 412 | client: |
| 413 | job_template: |
| 414 | test_workflow_template: |
| 415 | name: test-{{formula}}-workflow |
| 416 | template: |
| 417 | ... |
| 418 | param: |
| 419 | formula: ${_param:salt_formulas} |
| 420 | |
Filip Pytloun | 83129fc | 2017-02-23 10:07:32 +0100 | [diff] [blame] | 421 | Or simply define multiple jobs and it's parameters to replace from template: |
| 422 | |
| 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 Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 437 | |
Jakub Josef | 2a7739b | 2017-01-24 18:33:44 +0100 | [diff] [blame] | 438 | Purging undefined jobs from Jenkins |
| 439 | |
| 440 | .. code-block:: yaml |
| 441 | |
| 442 | jenkins: |
| 443 | client: |
| 444 | purge_jobs: true |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 445 | job: |
| 446 | my-amazing-job: |
| 447 | type: workflow |
Jakub Josef | 2a7739b | 2017-01-24 18:33:44 +0100 | [diff] [blame] | 448 | |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 449 | Plugins management from client |
| 450 | |
| 451 | .. code-block:: yaml |
| 452 | |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 453 | |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 454 | jenkins: |
| 455 | client: |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 456 | plugin_remove_unwanted: false |
| 457 | plugin_force_remove: false |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 458 | plugin: |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 459 | plugin1: 1.2.3 |
| 460 | plugin2: |
| 461 | plugin3: {} |
| 462 | plugin4: |
| 463 | version: 3.2.1 |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 464 | enabled: false |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 465 | plugin5: absent |
Jakub Josef | 10b4e10 | 2017-01-05 18:18:41 +0100 | [diff] [blame] | 466 | |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 467 | Adding plugin params to job |
| 468 | |
| 469 | .. code-block:: yaml |
| 470 | |
| 471 | |
| 472 | 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 Saienko | 661acf4 | 2018-01-18 10:37:07 +0200 | [diff] [blame] | 480 | max_concurrent_total: 1 |
| 481 | throttle_option: category #one of project (default or category) |
| 482 | categories: |
| 483 | - my_throuttle_category |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 484 | plugin: |
Alexander Evseev | cd836a1 | 2018-07-27 13:02:45 +0200 | [diff] [blame] | 485 | throttle-concurrents: |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 486 | |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 487 | LDAP configuration (depends on LDAP plugin) |
| 488 | |
| 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 | |
| 504 | |
| 505 | Matrix configuration (depends on auth-matrix plugin) |
| 506 | |
| 507 | .. code-block:: yaml |
| 508 | |
| 509 | jenkins: |
| 510 | client: |
| 511 | security: |
| 512 | matrix: |
Jakub Josef | 0ee470e | 2017-01-17 11:46:58 +0100 | [diff] [blame] | 513 | # set true for use ProjectMatrixAuthStrategy instead of GlobalMatrixAuthStrategy |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 514 | project_based: false |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 515 | permissions: |
| 516 | Jenkins: |
| 517 | # administrator access |
| 518 | ADMINISTER: |
| 519 | - admin |
| 520 | # read access (anonymous too) |
| 521 | READ: |
| 522 | - anonymous |
| 523 | - user1 |
| 524 | - user2 |
| 525 | # agents permissions |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 526 | MasterComputer: |
| 527 | BUILD: |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 528 | - user3 |
| 529 | # jobs permissions |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 530 | hudson: |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 531 | model: |
| 532 | Item: |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 533 | BUILD: |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 534 | - user4 |
| 535 | |
| 536 | `Common matrix strategies <https://github.com/arbabnazar/configuration/blob/c08a5eaf4e04a68d2481375502a926517097b253/playbooks/roles/tools_jenkins/templates/projectBasedMatrixSecurity.groovy.j2>`_ |
| 537 | |
Jakub Josef | 7bb17ab | 2017-01-12 14:52:53 +0100 | [diff] [blame] | 538 | Views enforcing from client |
| 539 | |
| 540 | .. code-block:: yaml |
| 541 | |
| 542 | jenkins: |
| 543 | client: |
| 544 | view: |
| 545 | my-list-view: |
| 546 | enabled: true |
| 547 | type: ListView |
Jakub Josef | 7d9fce3 | 2017-03-24 16:46:56 +0100 | [diff] [blame] | 548 | include_regex: ".*" |
Jakub Josef | 7bb17ab | 2017-01-12 14:52:53 +0100 | [diff] [blame] | 549 | my-view: |
| 550 | # set false to disable |
| 551 | enabled: true |
| 552 | type: MyView |
| 553 | |
| 554 | View specific params: |
| 555 | |
Jakub Josef | 7d9fce3 | 2017-03-24 16:46:56 +0100 | [diff] [blame] | 556 | - include_regex for ListView and CategorizedJobsView |
| 557 | - categories for CategorizedJobsView |
| 558 | |
| 559 | Categorized views |
| 560 | |
| 561 | .. code-block:: yaml |
| 562 | |
| 563 | jenkins: |
| 564 | client: |
| 565 | view: |
| 566 | my-categorized-view: |
| 567 | enabled: true |
| 568 | type: CategorizedJobsView |
| 569 | include_regex: ".*" |
| 570 | categories: |
| 571 | - group_regex: "aptly-.*-nightly-testing" |
| 572 | naming_rule: "Nightly -> Testing" |
| 573 | - group_regex: "aptly-.*-nightly-production" |
| 574 | naming_rule: "Nightly -> Production" |
Jakub Josef | 7bb17ab | 2017-01-12 14:52:53 +0100 | [diff] [blame] | 575 | |
Jakub Josef | 063a753 | 2017-01-11 15:48:01 +0100 | [diff] [blame] | 576 | |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 577 | Credentials enforcing from client |
| 578 | |
| 579 | .. code-block:: yaml |
Vasyl Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 580 | |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 581 | jenkins: |
| 582 | client: |
| 583 | credential: |
| 584 | cred_first: |
| 585 | username: admin |
| 586 | password: password |
| 587 | cred_second: |
| 588 | username: salt |
| 589 | password: password |
| 590 | cred_with_key: |
| 591 | username: admin |
| 592 | key: SOMESSHKEY |
Sergey Otpuschennikov | 1dd7799 | 2018-06-27 11:11:07 +0400 | [diff] [blame] | 593 | cred_with_text_secret: |
| 594 | secret: SOMETEXTSECRET |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 595 | |
| 596 | Users enforcing from client |
| 597 | |
| 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 | |
| 609 | Node enforcing from client using JNLP launcher |
| 610 | |
| 611 | .. code-block:: yaml |
| 612 | |
| 613 | jenkins: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 614 | 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 Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 627 | |
| 628 | Node enforcing from client using SSH launcher |
| 629 | |
| 630 | .. code-block:: yaml |
| 631 | |
| 632 | jenkins: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 633 | 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 Saienko | cb928a8 | 2018-01-17 15:21:28 +0200 | [diff] [blame] | 643 | - label |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 644 | launcher: |
| 645 | type: ssh |
| 646 | host: test-launcher |
| 647 | port: 22 |
| 648 | username: launcher-user |
| 649 | password: launcher-pass |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 650 | |
Jakub Josef | 1bb7f44 | 2017-05-26 17:02:56 +0200 | [diff] [blame] | 651 | Configure Jenkins master |
| 652 | |
| 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 | |
| 665 | |
Jakub Josef | 123be7a | 2016-12-12 16:02:36 +0100 | [diff] [blame] | 666 | Setting node labels |
| 667 | |
| 668 | .. code-block:: yaml |
| 669 | |
| 670 | jenkins: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 671 | client: |
| 672 | label: |
| 673 | node-name: |
| 674 | lbl_text: label-offline |
| 675 | append: false # set true for label append instead of replace |
Jakub Josef | d8e0429 | 2016-11-28 18:02:27 +0100 | [diff] [blame] | 676 | |
Jakub Josef | 60cc9d2 | 2017-01-18 12:02:14 +0100 | [diff] [blame] | 677 | SMTP server settings from client |
| 678 | |
| 679 | .. code-block:: yaml |
| 680 | |
| 681 | jenkins: |
| 682 | client: |
| 683 | smtp: |
| 684 | host: "smtp.domain.com" |
| 685 | username: "user@domain.cz" |
| 686 | password: "smtp-password" |
| 687 | port: 25 |
| 688 | ssl: false |
| 689 | reply_to: reply_to@address.com |
| 690 | |
Jakub Josef | dfb288c | 2017-04-27 17:29:00 +0200 | [diff] [blame] | 691 | Jenkins admin user email enforcement from client |
| 692 | |
| 693 | .. code-block:: yaml |
| 694 | |
| 695 | jenkins: |
| 696 | client: |
| 697 | smtp: |
| 698 | admin_email: "My Jenkins <jenkins@myserver.com>" |
| 699 | |
| 700 | |
Jakub Josef | a6d4c83 | 2017-01-19 14:06:12 +0100 | [diff] [blame] | 701 | Slack plugin configuration |
| 702 | |
| 703 | .. code-block:: yaml |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 704 | |
Jakub Josef | a6d4c83 | 2017-01-19 14:06:12 +0100 | [diff] [blame] | 705 | jenkins: |
| 706 | client: |
| 707 | slack: |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 708 | team_domain: example.com |
| 709 | token: slack-token |
| 710 | room: slack-room |
Jakub Josef | 6e0cda9 | 2017-02-14 18:01:58 +0100 | [diff] [blame] | 711 | token_credential_id: cred_id |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 712 | send_as: Some slack user |
Jakub Josef | a6d4c83 | 2017-01-19 14:06:12 +0100 | [diff] [blame] | 713 | |
Jakub Josef | 6e0cda9 | 2017-02-14 18:01:58 +0100 | [diff] [blame] | 714 | Pipeline global libraries setup |
| 715 | |
| 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 Josef | d8e0429 | 2016-11-28 18:02:27 +0100 | [diff] [blame] | 727 | |
Jakub Josef | 0194025 | 2017-05-10 14:01:22 +0200 | [diff] [blame] | 728 | Artifactory server enforcing |
| 729 | |
| 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 | |
Dmitry Burmistrov | a3f2c13 | 2018-04-10 16:24:25 +0400 | [diff] [blame] | 740 | Jenkins Global env properties enforcing |
Jakub Josef | 184ee1c | 2017-11-29 16:03:09 +0100 | [diff] [blame] | 741 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 742 | .. code-block:: yaml |
Jakub Josef | 184ee1c | 2017-11-29 16:03:09 +0100 | [diff] [blame] | 743 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 744 | jenkins: |
| 745 | client: |
| 746 | globalenvprop: |
| 747 | OFFLINE_DEPLOYMENT: |
| 748 | enabled: true |
| 749 | name: "OFFLINE_DEPLOYMENT" # optional, default using dict key |
| 750 | value: "true" |
Jakub Josef | 184ee1c | 2017-11-29 16:03:09 +0100 | [diff] [blame] | 751 | |
Dmitry Burmistrov | a3f2c13 | 2018-04-10 16:24:25 +0400 | [diff] [blame] | 752 | Throttle categories management from client (requires |
| 753 | `Throttle Concurrent Builds <https://plugins.jenkins.io/throttle-concurrents>`_ |
| 754 | plugin) |
| 755 | |
| 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 Burmistrov | 429b8ec | 2018-04-25 17:13:48 +0400 | [diff] [blame] | 773 | Jira sites management from client (requires |
| 774 | `JIRA <https://plugins.jenkins.io/jira>`_ plugin) |
| 775 | |
| 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 Otpuschennikov | 74ea268 | 2018-05-21 16:35:36 +0400 | [diff] [blame] | 805 | |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 806 | Gerrit trigger plugin configuration |
| 807 | |
| 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 Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 820 | build_current_patches_only: true |
| 821 | abort_new_patchsets: false |
| 822 | abort_manual_patchsets: false |
| 823 | abort_same_topic: false |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 824 | 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 Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 833 | build_current_patches_only: true |
| 834 | abort_new_patchsets: false |
| 835 | abort_manual_patchsets: false |
| 836 | abort_same_topic: false |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 837 | authkey: | |
| 838 | SOMESSHKEY |
Dmitry Burmistrov | 429b8ec | 2018-04-25 17:13:48 +0400 | [diff] [blame] | 839 | |
Dmitry Burmistrov | 2953edf | 2018-05-24 11:32:54 +0400 | [diff] [blame] | 840 | CSRF Protection configuration |
| 841 | |
| 842 | .. code-block:: yaml |
| 843 | |
| 844 | jenkins: |
| 845 | client: |
| 846 | security: |
| 847 | csrf: |
| 848 | enabled: true |
| 849 | proxy_compat: false |
| 850 | |
| 851 | |
| 852 | Agent to Master Access Control |
| 853 | |
| 854 | .. code-block:: yaml |
| 855 | |
| 856 | jenkins: |
| 857 | client: |
| 858 | security: |
| 859 | agent2master: |
| 860 | enabled: true |
| 861 | whitelisted: '' |
| 862 | file_path_rules: '' |
| 863 | |
| 864 | Content Security Policy configuration |
| 865 | |
| 866 | .. code-block:: yaml |
| 867 | |
| 868 | jenkins: |
| 869 | client: |
| 870 | security: |
| 871 | csp: "sandbox; default-src 'none'; img-src 'self'; style-src 'self';" |
| 872 | |
| 873 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 874 | Usage |
| 875 | ===== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 876 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 877 | Generate password hash: |
| 878 | |
| 879 | .. code-block:: bash |
| 880 | |
| 881 | echo -n "salt{plainpassword}" | openssl dgst -sha256 |
| 882 | |
| 883 | Place in the configuration ``salt:hashpassword``. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 884 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 885 | |
| 886 | External links |
| 887 | ============== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 888 | |
| 889 | * https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins |
Filip Pytloun | adf72fa | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 890 | |
Ales Komarek | ffe8bb2 | 2017-02-09 11:10:16 +0100 | [diff] [blame] | 891 | |
Filip Pytloun | adf72fa | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 892 | Documentation and Bugs |
| 893 | ====================== |
| 894 | |
| 895 | To learn how to install and update salt-formulas, consult the documentation |
| 896 | available online at: |
| 897 | |
| 898 | http://salt-formulas.readthedocs.io/ |
| 899 | |
| 900 | In the unfortunate event that bugs are discovered, they should be reported to |
| 901 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 902 | formula: |
| 903 | |
| 904 | https://github.com/salt-formulas/salt-formula-jenkins/issues |
| 905 | |
| 906 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 907 | use Launchpad salt-formulas project: |
| 908 | |
| 909 | https://launchpad.net/salt-formulas |
| 910 | |
| 911 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 912 | |
| 913 | https://launchpad.net/~salt-formulas-users |
| 914 | |
| 915 | Developers wishing to work on the salt-formulas projects should always base |
| 916 | their work on master branch and submit pull request against specific formula. |
| 917 | |
| 918 | https://github.com/salt-formulas/salt-formula-jenkins |
| 919 | |
| 920 | Any questions or feedback is always welcome so feel free to join our IRC |
| 921 | channel: |
| 922 | |
| 923 | #salt-formulas @ irc.freenode.net |