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