blob: 20658907e824c85603a3b0abb85d4ac11b8ab77c [file] [log] [blame]
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +02001=======
2Jenkins
3=======
4
Ales Komarek4c0bab12016-01-22 12:10:50 +01005Jenkins is an application that monitors executions of repeated jobs, such as building a software project or jobs run by cron.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +02006
7Available states
8================
9
10.. contents::
11 :local:
12
13``jenkins.master``
14------------------
15
Ales Komareke5a1ed62016-08-27 12:02:48 +020016Setup jenkins master.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020017
18``jenkins.slave``
19-----------------
20
Ales Komareke5a1ed62016-08-27 12:02:48 +020021Setup jenkins slave.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020022
23``jenkins.job_builder``
24-----------------------
25
Ales Komareke5a1ed62016-08-27 12:02:48 +020026Setup jenkins job builder.
27
28``jenkins.client``
29------------------
30
31Setup jenkins client, works with Salt 2016.3+, supports pipeline workflow projects only now.
32
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020033
34Available metadata
35==================
36
37.. contents::
38 :local:
39
40``metadata.jenkins.master.single``
41----------------------------------
42
43Setup single-node master
44
45
46``metadata.jenkins.slave.single``
47---------------------------------
48
49Setup Jenkins slave
50
Ales Komareke5a1ed62016-08-27 12:02:48 +020051Sample pillars
52==============
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020053
Ales Komarek4c0bab12016-01-22 12:10:50 +010054Jenkins master
Ales Komareke5a1ed62016-08-27 12:02:48 +020055--------------
56
57Simple master with reverse proxy
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020058
59.. code-block:: yaml
60
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020061 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 Pytloun52b9c2c2016-01-28 13:45:57 +010078 # Do not manage config.xml from Salt, use UI instead
79 no_config: true
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +020080 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 Komareke5a1ed62016-08-27 12:02:48 +0200101Agent (former slave)
102--------------------
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200103
104.. code-block:: yaml
105
Ales Komarek4c0bab12016-01-22 12:10:50 +0100106 jenkins:
107 slave:
108 master:
109 host: jenkins.example.com
110 port: 80
Michael Kutý37a35952016-06-10 23:51:36 +0200111 protocol: http
Ales Komarek4c0bab12016-01-22 12:10:50 +0100112 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 Komareke5a1ed62016-08-27 12:02:48 +0200123Client
124------
125
126Simple 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 Komarekdaf31f72016-08-29 11:00:13 +0200153Inline Groovy script samples
Ales Komareke5a1ed62016-08-27 12:02:48 +0200154
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
Ales Komarek5b672fd2016-08-29 16:05:03 +0200163 script:
164 content: |
165 node {
166 stage 'Stage 1'
167 echo 'Hello World 1'
168 stage 'Stage 2'
169 echo 'Hello World 2'
170 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200171 test_workflow_jenkins_input:
172 type: workflow
173 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200174 script:
175 content: |
176 node {
177 stage 'Enter string'
178 input message: 'Enter job parameters', ok: 'OK', parameters: [
179 string(defaultValue: 'default', description: 'Enter a string.', name: 'string'),
180 ]
181 stage 'Enter boolean'
182 input message: 'Enter job parameters', ok: 'OK', parameters: [
183 booleanParam(defaultValue: false, description: 'Select boolean.', name: 'Bool'),
184 ]
185 stage 'Enter text'
186 input message: 'Enter job parameters', ok: 'OK', parameters: [
187 text(defaultValue: '', description: 'Enter multiline', name: 'Multiline')
188 ]
189 }
Ales Komareke5a1ed62016-08-27 12:02:48 +0200190
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200191
Ales Komarekdaf31f72016-08-29 11:00:13 +0200192GIT controlled groovy script samples
193
194.. code-block:: yaml
195
196 jenkins:
197 client:
198 source:
Ales Komarek5b672fd2016-08-29 16:05:03 +0200199 base:
200 engine: git
201 address: repo_url
202 branch: branch
203 domain:
204 engine: git
205 address: domain_url
206 branch: branch
Ales Komarekdaf31f72016-08-29 11:00:13 +0200207 job:
208 test_workflow_jenkins_simple:
209 type: workflow
210 display_name: Test jenkins simple workflow
Ales Komarek5b672fd2016-08-29 16:05:03 +0200211 param:
212 bool_param:
213 type: boolean
214 description: true/false
215 default: true
216 script:
217 repository: base
218 file: workflows/test_workflow_jenkins_simple.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200219 test_workflow_jenkins_input:
220 type: workflow
221 display_name: Test jenkins workflow inputs
Ales Komarek5b672fd2016-08-29 16:05:03 +0200222 script:
223 repository: domain
224 file: workflows/test_workflow_jenkins_input.groovy
225 test_workflow_jenkins_input_jenkinsfile:
226 type: workflow
227 display_name: Test jenkins workflow inputs (jenknisfile)
228 script:
229 repository: domain
230 file: workflows/test_workflow_jenkins_input/Jenkinsfile
Ales Komarekdaf31f72016-08-29 11:00:13 +0200231
Ales Komarek5b672fd2016-08-29 16:05:03 +0200232GIT controlled groovy script with shared libraries
233
234.. code-block:: yaml
235
236 jenkins:
237 client:
238 source:
239 base:
240 engine: git
241 address: repo_url
242 branch: branch
243 domain:
244 engine: git
245 address: domain_url
246 branch: branch
247 job:
248 test_workflow_jenkins_simple:
249 type: workflow
250 display_name: Test jenkins simple workflow
251 param:
252 bool_param:
253 type: boolean
254 description: true/false
255 default: true
256 script:
257 repository: base
258 file: workflows/test_workflow_jenkins_simple.groovy
259 libs:
260 - repository: base
261 file: macros/cookiecutter.groovy
262 - repository: base
263 file: macros/git.groovy
Ales Komarekdaf31f72016-08-29 11:00:13 +0200264
Ales Komarek4c0bab12016-01-22 12:10:50 +0100265Usage
266=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200267
Ales Komarek4c0bab12016-01-22 12:10:50 +0100268Generate password hash:
269
270.. code-block:: bash
271
272 echo -n "salt{plainpassword}" | openssl dgst -sha256
273
274Place in the configuration ``salt:hashpassword``.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200275
276Read more
277=========
278
279* https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins