blob: c11b4cf6d787f30cab593442a1c48a43c59a083f [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
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 Pytloun8bfd2bf2015-10-06 16:28:32 +0200189
Ales Komarekdaf31f72016-08-29 11:00:13 +0200190GIT 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 Komarek4c0bab12016-01-22 12:10:50 +0100211Usage
212=====
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200213
Ales Komarek4c0bab12016-01-22 12:10:50 +0100214Generate password hash:
215
216.. code-block:: bash
217
218 echo -n "salt{plainpassword}" | openssl dgst -sha256
219
220Place in the configuration ``salt:hashpassword``.
Filip Pytloun8bfd2bf2015-10-06 16:28:32 +0200221
222Read more
223=========
224
225* https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins