Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | ======= |
| 2 | Jenkins |
| 3 | ======= |
| 4 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 5 | Jenkins is an application that monitors executions of repeated jobs, such as building a software project or jobs run by cron. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 6 | |
| 7 | Available states |
| 8 | ================ |
| 9 | |
| 10 | .. contents:: |
| 11 | :local: |
| 12 | |
| 13 | ``jenkins.master`` |
| 14 | ------------------ |
| 15 | |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 16 | Setup jenkins master. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 17 | |
| 18 | ``jenkins.slave`` |
| 19 | ----------------- |
| 20 | |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 21 | Setup jenkins slave. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 22 | |
| 23 | ``jenkins.job_builder`` |
| 24 | ----------------------- |
| 25 | |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 26 | Setup jenkins job builder. |
| 27 | |
| 28 | ``jenkins.client`` |
| 29 | ------------------ |
| 30 | |
| 31 | Setup jenkins client, works with Salt 2016.3+, supports pipeline workflow projects only now. |
| 32 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 33 | |
| 34 | Available metadata |
| 35 | ================== |
| 36 | |
| 37 | .. contents:: |
| 38 | :local: |
| 39 | |
| 40 | ``metadata.jenkins.master.single`` |
| 41 | ---------------------------------- |
| 42 | |
| 43 | Setup single-node master |
| 44 | |
| 45 | |
| 46 | ``metadata.jenkins.slave.single`` |
| 47 | --------------------------------- |
| 48 | |
| 49 | Setup Jenkins slave |
| 50 | |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 51 | Sample pillars |
| 52 | ============== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 53 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 54 | Jenkins master |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 55 | -------------- |
| 56 | |
| 57 | Simple master with reverse proxy |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 58 | |
| 59 | .. code-block:: yaml |
| 60 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 61 | nginx: |
| 62 | server: |
| 63 | site: |
| 64 | jenkins: |
| 65 | enabled: true |
| 66 | type: nginx_proxy |
| 67 | name: jenkins |
| 68 | proxy: |
| 69 | host: 127.0.0.1 |
| 70 | port: 8080 |
| 71 | protocol: http |
| 72 | host: |
| 73 | name: jenkins.example.com |
| 74 | port: 80 |
| 75 | jenkins: |
| 76 | master: |
| 77 | mode: EXCLUSIVE |
Filip Pytloun | 52b9c2c | 2016-01-28 13:45:57 +0100 | [diff] [blame] | 78 | # Do not manage config.xml from Salt, use UI instead |
| 79 | no_config: true |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 80 | slaves: |
| 81 | - name: slave01 |
| 82 | label: pbuilder |
| 83 | executors: 2 |
| 84 | - name: slave02 |
| 85 | label: image_builder |
| 86 | mode: EXCLUSIVE |
| 87 | executors: 2 |
| 88 | views: |
| 89 | - name: "Package builds" |
| 90 | regex: "debian-build-.*" |
| 91 | - name: "Contrail builds" |
| 92 | regex: "contrail-build-.*" |
| 93 | - name: "Aptly" |
| 94 | regex: "aptly-.*" |
| 95 | plugins: |
| 96 | - name: slack |
| 97 | - name: extended-choice-parameter |
| 98 | - name: rebuild |
| 99 | - name: test-stability |
| 100 | |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 101 | Agent (former slave) |
| 102 | -------------------- |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 103 | |
| 104 | .. code-block:: yaml |
| 105 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 106 | jenkins: |
| 107 | slave: |
| 108 | master: |
| 109 | host: jenkins.example.com |
| 110 | port: 80 |
Michael KutĂ˝ | 37a3595 | 2016-06-10 23:51:36 +0200 | [diff] [blame] | 111 | protocol: http |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 112 | user: |
| 113 | name: jenkins_slave |
| 114 | password: dexiech6AepohthaiHook2iesh7ol5ook4Ov3leid3yek6daid2ooNg3Ee2oKeYo |
| 115 | gpg: |
| 116 | keypair_id: A76882D3 |
| 117 | public_key: | |
| 118 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 119 | ... |
| 120 | private_key: | |
| 121 | -----BEGIN PGP PRIVATE KEY BLOCK----- |
| 122 | ... |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 123 | Client |
| 124 | ------ |
| 125 | |
| 126 | Simple client with workflow job definition |
| 127 | |
| 128 | .. code-block:: yaml |
| 129 | |
| 130 | jenkins: |
| 131 | client: |
| 132 | master: |
| 133 | host: jenkins.example.com |
| 134 | port: 80 |
| 135 | protocol: http |
| 136 | job: |
| 137 | jobname: |
| 138 | type: workflow |
| 139 | param: |
| 140 | bool_param: |
| 141 | type: boolean |
| 142 | description: true/false |
| 143 | default: true |
| 144 | string_param: |
| 145 | type: string |
| 146 | description: 1 liner |
| 147 | default: default_string |
| 148 | text_param: |
| 149 | type: text |
| 150 | description: multi-liner |
| 151 | default: default_text |
| 152 | |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame^] | 153 | Inline Groovy script samples |
Ales Komarek | e5a1ed6 | 2016-08-27 12:02:48 +0200 | [diff] [blame] | 154 | |
| 155 | .. code-block:: yaml |
| 156 | |
| 157 | jenkins: |
| 158 | client: |
| 159 | job: |
| 160 | test_workflow_jenkins_simple: |
| 161 | type: workflow |
| 162 | display_name: Test jenkins simple workflow |
| 163 | script: | |
| 164 | node { |
| 165 | stage 'Stage 1' |
| 166 | echo 'Hello World 1' |
| 167 | stage 'Stage 2' |
| 168 | echo 'Hello World 2' |
| 169 | } |
| 170 | test_workflow_jenkins_input: |
| 171 | type: workflow |
| 172 | display_name: Test jenkins workflow inputs |
| 173 | script: | |
| 174 | node { |
| 175 | stage 'Enter string' |
| 176 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 177 | string(defaultValue: 'default', description: 'Enter a string.', name: 'string'), |
| 178 | ] |
| 179 | stage 'Enter boolean' |
| 180 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 181 | booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'), |
| 182 | ] |
| 183 | stage 'Enter text' |
| 184 | input message: 'Enter job parameters', ok: 'OK', parameters: [ |
| 185 | text(defaultValue: '', description: 'Enter multiline', name: 'Multiline') |
| 186 | ] |
| 187 | } |
| 188 | |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 189 | |
Ales Komarek | daf31f7 | 2016-08-29 11:00:13 +0200 | [diff] [blame^] | 190 | GIT controlled groovy script samples |
| 191 | |
| 192 | .. code-block:: yaml |
| 193 | |
| 194 | jenkins: |
| 195 | client: |
| 196 | source: |
| 197 | engine: git |
| 198 | address: repo_url |
| 199 | branch: branch |
| 200 | job: |
| 201 | test_workflow_jenkins_simple: |
| 202 | type: workflow |
| 203 | display_name: Test jenkins simple workflow |
| 204 | script_file: jobs/test_workflow_jenkins_simple.groovy |
| 205 | test_workflow_jenkins_input: |
| 206 | type: workflow |
| 207 | display_name: Test jenkins workflow inputs |
| 208 | script_file: jobs/test_workflow_jenkins_input.groovy |
| 209 | |
| 210 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 211 | Usage |
| 212 | ===== |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 213 | |
Ales Komarek | 4c0bab1 | 2016-01-22 12:10:50 +0100 | [diff] [blame] | 214 | Generate password hash: |
| 215 | |
| 216 | .. code-block:: bash |
| 217 | |
| 218 | echo -n "salt{plainpassword}" | openssl dgst -sha256 |
| 219 | |
| 220 | Place in the configuration ``salt:hashpassword``. |
Filip Pytloun | 8bfd2bf | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 221 | |
| 222 | Read more |
| 223 | ========= |
| 224 | |
| 225 | * https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins |