jenkins_pipeline_builder 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +101 -13
- data/bin/generate +1 -1
- data/commit_build.sh +7 -0
- data/jenkins_pipeline_builder.gemspec +1 -1
- data/lib/{jenksin_pipeline_builder.rb → jenkins_pipeline_builder.rb} +16 -16
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/builders.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/cli/base.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/cli/helper.rb +2 -1
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/cli/pipeline.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/cli/view.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/compiler.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/generator.rb +32 -16
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/job_builder.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/module_registry.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/publishers.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/triggers.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/utils.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/version.rb +1 -1
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/view.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/wrappers.rb +0 -0
- data/lib/{jenksin_pipeline_builder → jenkins_pipeline_builder}/xml_helper.rb +0 -0
- data/spec/func_tests/spec_helper.rb +1 -1
- data/spec/unit_tests/fixtures/files/project.yaml +1 -1
- data/spec/unit_tests/fixtures/templates/external_job.yaml +4 -0
- data/spec/unit_tests/fixtures/templates/project_with_jobs.yaml +25 -0
- data/spec/unit_tests/resolve_dependencies_spec.rb +1 -1
- data/spec/unit_tests/spec_helper.rb +2 -2
- metadata +24 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc9e61ea35987e7d0f6d0504fb55378c755df1b
|
4
|
+
data.tar.gz: c74fa0ad124aa3a4b41b941593836846cb608437
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59cf44be2dff1d951273e2a026708cb354bfcb6581daa164b64c058593d7add78b8c7a6a34253272019c2886fbd664ce2545bf3bd2e371fd7c44c6769b4dcd7b
|
7
|
+
data.tar.gz: e86d64a7cae810430373278a39990c3046e2c247f2af2c5c8c887f51073c322974cb529f779643c30cf772d00024e1735bb57cdadfd940e282fc1891ff71d4e9
|
data/README.md
CHANGED
@@ -4,15 +4,20 @@ jenkins-pipeline-builder
|
|
4
4
|
YAML driven CI Jenkins Pipeline Builder enabling to version your artifact pipelines alongside with the artifact source itself.
|
5
5
|
|
6
6
|
|
7
|
-
#
|
7
|
+
# Background
|
8
|
+
|
9
|
+
This project is inspired by a great work done by Arangamani with [jenkins_api_client](https://github.com/arangamani/jenkins_api_client) and
|
10
|
+
amazing progress done by the Open Stack community with their [jenkins-job-builder](http://ci.openstack.org/jenkins-job-builder/)
|
8
11
|
|
9
|
-
|
12
|
+
The YAML structure very closely resembles the OpenStack Job Builder, but, in comparison to Python version, is 100%
|
13
|
+
pure Ruby and uses Jenkins API Client and has additional functionlity of building different types of Jenkins views.
|
10
14
|
|
11
|
-
|
15
|
+
# JenkinsPipeline::Generator
|
12
16
|
|
13
|
-
|
17
|
+
USAGE:
|
18
|
+
------
|
14
19
|
|
15
|
-
|
20
|
+
### Installation
|
16
21
|
|
17
22
|
Add this line to your application's Gemfile:
|
18
23
|
|
@@ -30,17 +35,43 @@ Or install it yourself as:
|
|
30
35
|
[optional] brew link libxml2 libxslt
|
31
36
|
gem install nokogiri
|
32
37
|
|
33
|
-
|
38
|
+
### Authentication
|
39
|
+
|
40
|
+
For more info see [jenkins_api_client](https://github.com/arangamani/jenkins_api_client).
|
41
|
+
Supplying credentials to the client is optional, as not all Jenkins instances
|
42
|
+
require authentication. This project supports two types of password-based
|
43
|
+
authentication. You can just you the plain password by using <tt>password</tt>
|
44
|
+
parameter. If you don't prefer leaving plain passwords in the credentials file,
|
45
|
+
you can encode your password in base64 format and use <tt>password_base64</tt>
|
46
|
+
parameter to specify the password either in the arguments or in the credentials
|
47
|
+
file. To use the client without credentials, just leave out the
|
48
|
+
<tt>username</tt> and <tt>password</tt> parameters. The <tt>password</tt>
|
49
|
+
parameter is only required if <tt>username</tt> is specified.
|
50
|
+
|
51
|
+
#### Using with Open ID
|
52
|
+
|
53
|
+
For more info see [jenkins_api_client](https://github.com/arangamani/jenkins_api_client).
|
54
|
+
It is very simple to authenticate with your Jenkins server that has Open ID
|
55
|
+
authentication enabled. You will have to obtain your API token and use the API
|
56
|
+
token as the password. For obtaining the API token, go to your user configuration
|
57
|
+
page and click 'Show API Token'. Use this token for the `password` parameter when
|
58
|
+
initializing the client.
|
59
|
+
|
60
|
+
### Basic usage
|
61
|
+
|
62
|
+
Create all your Job description files in a folder (Ex.: ./pipeline). Follow the Job/View/Project DSL.
|
63
|
+
Try to extract the reusable values out of jobs into the project.
|
34
64
|
|
35
|
-
|
65
|
+
Put the right information about the location of your Jenkins server and the appropriate credentials
|
66
|
+
in a config file (ex: config.login.yml)
|
36
67
|
|
37
|
-
|
68
|
+
Now you ready to bootstrap a pipeline:
|
38
69
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
70
|
+
generate pipeline -d -c config/login.yml bootstrap ./pipeline
|
71
|
+
|
72
|
+
|
73
|
+
DSL:
|
74
|
+
----
|
44
75
|
|
45
76
|
## Job DSL
|
46
77
|
Here's a high level overview of what's available:
|
@@ -134,3 +165,60 @@ Here's a high level overview of what's available:
|
|
134
165
|
build("job_name2", param1: build21.environment.get("some_var"))
|
135
166
|
}
|
136
167
|
```
|
168
|
+
|
169
|
+
### View DSL
|
170
|
+
```yaml
|
171
|
+
- view:
|
172
|
+
name: 'view name'
|
173
|
+
type: 'listview' # Optional: listview [default], myview, nestedView, categorizedView, dashboardView, multijobView
|
174
|
+
description: 'description'
|
175
|
+
regex: '.*'
|
176
|
+
groupingRules:
|
177
|
+
- groupRegex: "1.*"
|
178
|
+
namingRule: "sub view"
|
179
|
+
```
|
180
|
+
|
181
|
+
### Project DSL
|
182
|
+
```yaml
|
183
|
+
- project:
|
184
|
+
name: Your project name
|
185
|
+
jobs:
|
186
|
+
- Job1
|
187
|
+
- Job2
|
188
|
+
param1: value1
|
189
|
+
- JobTemplate1
|
190
|
+
```
|
191
|
+
|
192
|
+
### Default Settings Section
|
193
|
+
|
194
|
+
The defaults section mimics behavior of [jenkins-job-builder Defaults](http://ci.openstack.org/jenkins-job-builder/configuration.html#defaults)
|
195
|
+
If a set of Defaults is specified with the name global, that will be used by all Job (and Job Template) definitions.
|
196
|
+
|
197
|
+
```yaml
|
198
|
+
- defaults:
|
199
|
+
name: global
|
200
|
+
param1: 'value 1'
|
201
|
+
```
|
202
|
+
|
203
|
+
|
204
|
+
CONTRIBUTING:
|
205
|
+
----------------
|
206
|
+
|
207
|
+
If you would like to contribute to this project, just do the following:
|
208
|
+
|
209
|
+
1. Fork the repo on Github.
|
210
|
+
2. Add your features and make commits to your forked repo.
|
211
|
+
3. Make a pull request to this repo.
|
212
|
+
4. Review will be done and changes will be requested.
|
213
|
+
5. Once changes are done or no changes are required, pull request will be merged.
|
214
|
+
6. The next release will have your changes in it.
|
215
|
+
|
216
|
+
Please take a look at the issues page if you want to get started.
|
217
|
+
|
218
|
+
FEATURE REQUEST:
|
219
|
+
----------------
|
220
|
+
|
221
|
+
If you use this gem for your project and you think it would be nice to have a
|
222
|
+
particular feature that is presently not implemented, I would love to hear that
|
223
|
+
and consider working on it. Just open an issue in Github as a feature request.
|
224
|
+
|
data/bin/generate
CHANGED
data/commit_build.sh
ADDED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'jenkins_pipeline_builder/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'jenkins_pipeline_builder'
|
@@ -20,20 +20,20 @@
|
|
20
20
|
# THE SOFTWARE.
|
21
21
|
#
|
22
22
|
|
23
|
-
require '
|
24
|
-
require '
|
25
|
-
require '
|
26
|
-
require '
|
27
|
-
require '
|
28
|
-
require '
|
29
|
-
require '
|
30
|
-
require '
|
31
|
-
require '
|
32
|
-
require '
|
33
|
-
require '
|
34
|
-
require '
|
23
|
+
require 'jenkins_pipeline_builder/version'
|
24
|
+
require 'jenkins_pipeline_builder/utils'
|
25
|
+
require 'jenkins_pipeline_builder/xml_helper'
|
26
|
+
require 'jenkins_pipeline_builder/compiler'
|
27
|
+
require 'jenkins_pipeline_builder/job_builder'
|
28
|
+
require 'jenkins_pipeline_builder/module_registry'
|
29
|
+
require 'jenkins_pipeline_builder/builders'
|
30
|
+
require 'jenkins_pipeline_builder/wrappers'
|
31
|
+
require 'jenkins_pipeline_builder/triggers'
|
32
|
+
require 'jenkins_pipeline_builder/publishers'
|
33
|
+
require 'jenkins_pipeline_builder/view'
|
34
|
+
require 'jenkins_pipeline_builder/generator'
|
35
35
|
|
36
|
-
require '
|
37
|
-
require '
|
38
|
-
require '
|
39
|
-
require '
|
36
|
+
require 'jenkins_pipeline_builder/cli/helper'
|
37
|
+
require 'jenkins_pipeline_builder/cli/view'
|
38
|
+
require 'jenkins_pipeline_builder/cli/pipeline'
|
39
|
+
require 'jenkins_pipeline_builder/cli/base'
|
File without changes
|
File without changes
|
@@ -41,8 +41,9 @@ module JenkinsPipelineBuilder
|
|
41
41
|
creds = options
|
42
42
|
elsif options[:creds_file]
|
43
43
|
creds = YAML.load_file(
|
44
|
+
File.expand_path(options[:creds_file])
|
44
45
|
#File.expand_path(options[:creds_file], __FILE__)
|
45
|
-
options[:creds_file]
|
46
|
+
#options[:creds_file]
|
46
47
|
)
|
47
48
|
elsif File.exist?("#{ENV['HOME']}/.jenkins_api_client/login.yml")
|
48
49
|
creds = YAML.load_file(
|
File without changes
|
File without changes
|
File without changes
|
@@ -110,7 +110,7 @@ module JenkinsPipelineBuilder
|
|
110
110
|
def load_collection_from_path(path, recursively = false)
|
111
111
|
if File.directory?(path)
|
112
112
|
@logger.info "Generating from folder #{path}"
|
113
|
-
Dir.
|
113
|
+
Dir[File.join(path, '/*.yaml'), File.join(path, '/*.yml')].each do |file|
|
114
114
|
if File.directory?(file)
|
115
115
|
if recursively
|
116
116
|
load_collection_from_path(File.join(path, file), recursively)
|
@@ -194,30 +194,46 @@ module JenkinsPipelineBuilder
|
|
194
194
|
return result
|
195
195
|
end
|
196
196
|
|
197
|
+
def jobs
|
198
|
+
result = []
|
199
|
+
@job_collection.values.each do |item|
|
200
|
+
result << item if item[:type] == :job
|
201
|
+
end
|
202
|
+
return result
|
203
|
+
end
|
204
|
+
|
197
205
|
def bootstrap(path)
|
198
206
|
@logger.info "Bootstrapping pipeline from path #{path}"
|
199
207
|
load_collection_from_path(path)
|
200
208
|
|
201
|
-
projects
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
job = i[:result]
|
208
|
-
xml = compile_job_to_xml(job)
|
209
|
-
create_or_update(job, xml)
|
210
|
-
end
|
209
|
+
# Publish all the jobs if the projects are not found
|
210
|
+
if projects.count == 0
|
211
|
+
jobs.each do |i|
|
212
|
+
job = i[:value]
|
213
|
+
xml = compile_job_to_xml(job)
|
214
|
+
create_or_update(job, xml)
|
211
215
|
end
|
216
|
+
else
|
217
|
+
projects.each do |project|
|
218
|
+
compiled_project = resolve_project(project)
|
219
|
+
#pp compiled_project
|
220
|
+
|
221
|
+
if compiled_project[:value][:jobs]
|
222
|
+
compiled_project[:value][:jobs].each do |i|
|
223
|
+
job = i[:result]
|
224
|
+
xml = compile_job_to_xml(job)
|
225
|
+
create_or_update(job, xml)
|
226
|
+
end
|
227
|
+
end
|
212
228
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
229
|
+
if compiled_project[:value][:views]
|
230
|
+
compiled_project[:value][:views].each do |v|
|
231
|
+
_view = v[:result]
|
232
|
+
view.create(_view)
|
233
|
+
end
|
217
234
|
end
|
218
235
|
end
|
219
236
|
end
|
220
|
-
|
221
237
|
end
|
222
238
|
|
223
239
|
def dump(job_name)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -6,7 +6,7 @@ require 'simplecov-rcov'
|
|
6
6
|
|
7
7
|
SimpleCov.start if ENV["COVERAGE"]
|
8
8
|
|
9
|
-
require File.expand_path('../../../lib/
|
9
|
+
require File.expand_path('../../../lib/jenkins_pipeline_builder', __FILE__)
|
10
10
|
|
11
11
|
RSpec.configure do |config|
|
12
12
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
@@ -0,0 +1,25 @@
|
|
1
|
+
- job-template:
|
2
|
+
name: '{{name}}-unit-tests'
|
3
|
+
builders:
|
4
|
+
- shell: unittest
|
5
|
+
publishers:
|
6
|
+
- email:
|
7
|
+
recipients: '{{mail-to}}'
|
8
|
+
|
9
|
+
- job-template:
|
10
|
+
name: '{{name}}-perf-tests'
|
11
|
+
builders:
|
12
|
+
- shell: perftest
|
13
|
+
publishers:
|
14
|
+
- email:
|
15
|
+
recipients: '{{mail-to}}'
|
16
|
+
|
17
|
+
- project:
|
18
|
+
name: project-name
|
19
|
+
db: my_own_db
|
20
|
+
jobs:
|
21
|
+
- '{{name}}-unit-tests':
|
22
|
+
mail-to: developer@nowhere.net
|
23
|
+
- '{{name}}-perf-tests':
|
24
|
+
mail-to: projmanager@nowhere.net
|
25
|
+
- foo-test
|
@@ -208,7 +208,7 @@ describe 'Templates resolver' do
|
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'shoult resolve job template into a job' do
|
211
|
-
file = '
|
211
|
+
file = 'project_with_jobs'
|
212
212
|
path = File.expand_path('../fixtures/templates/' + file, __FILE__)
|
213
213
|
project = YAML.load_file(path + '.yaml')
|
214
214
|
|
@@ -5,7 +5,7 @@ require 'simplecov'
|
|
5
5
|
require 'simplecov-rcov'
|
6
6
|
|
7
7
|
SimpleCov.profiles.define 'spec' do
|
8
|
-
add_group '
|
8
|
+
add_group 'jenkins_pipeline_builder', '/lib/'
|
9
9
|
coverage_dir 'out/coverage'
|
10
10
|
formatter SimpleCov::Formatter::MultiFormatter[
|
11
11
|
SimpleCov::Formatter::Console,
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
|
22
22
|
SimpleCov.start 'spec' #if ENV["COVERAGE"]
|
23
23
|
|
24
|
-
require File.expand_path('../../../lib/
|
24
|
+
require File.expand_path('../../../lib/jenkins_pipeline_builder', __FILE__)
|
25
25
|
|
26
26
|
RSpec.configure do |config|
|
27
27
|
config.before(:each) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenkins_pipeline_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Moochnick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -265,25 +265,26 @@ files:
|
|
265
265
|
- README.md
|
266
266
|
- Rakefile
|
267
267
|
- bin/generate
|
268
|
+
- commit_build.sh
|
268
269
|
- config/login.yml
|
269
270
|
- jenkins_pipeline_builder.gemspec
|
270
|
-
- lib/
|
271
|
-
- lib/
|
272
|
-
- lib/
|
273
|
-
- lib/
|
274
|
-
- lib/
|
275
|
-
- lib/
|
276
|
-
- lib/
|
277
|
-
- lib/
|
278
|
-
- lib/
|
279
|
-
- lib/
|
280
|
-
- lib/
|
281
|
-
- lib/
|
282
|
-
- lib/
|
283
|
-
- lib/
|
284
|
-
- lib/
|
285
|
-
- lib/
|
286
|
-
- lib/
|
271
|
+
- lib/jenkins_pipeline_builder.rb
|
272
|
+
- lib/jenkins_pipeline_builder/builders.rb
|
273
|
+
- lib/jenkins_pipeline_builder/cli/base.rb
|
274
|
+
- lib/jenkins_pipeline_builder/cli/helper.rb
|
275
|
+
- lib/jenkins_pipeline_builder/cli/pipeline.rb
|
276
|
+
- lib/jenkins_pipeline_builder/cli/view.rb
|
277
|
+
- lib/jenkins_pipeline_builder/compiler.rb
|
278
|
+
- lib/jenkins_pipeline_builder/generator.rb
|
279
|
+
- lib/jenkins_pipeline_builder/job_builder.rb
|
280
|
+
- lib/jenkins_pipeline_builder/module_registry.rb
|
281
|
+
- lib/jenkins_pipeline_builder/publishers.rb
|
282
|
+
- lib/jenkins_pipeline_builder/triggers.rb
|
283
|
+
- lib/jenkins_pipeline_builder/utils.rb
|
284
|
+
- lib/jenkins_pipeline_builder/version.rb
|
285
|
+
- lib/jenkins_pipeline_builder/view.rb
|
286
|
+
- lib/jenkins_pipeline_builder/wrappers.rb
|
287
|
+
- lib/jenkins_pipeline_builder/xml_helper.rb
|
287
288
|
- spec/func_tests/spec_helper.rb
|
288
289
|
- spec/func_tests/view_spec.rb
|
289
290
|
- spec/unit_tests/compiler_spec.rb
|
@@ -301,6 +302,8 @@ files:
|
|
301
302
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.xml
|
302
303
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.yaml
|
303
304
|
- spec/unit_tests/fixtures/files/project.yaml
|
305
|
+
- spec/unit_tests/fixtures/templates/external_job.yaml
|
306
|
+
- spec/unit_tests/fixtures/templates/project_with_jobs.yaml
|
304
307
|
- spec/unit_tests/generator_spec.rb
|
305
308
|
- spec/unit_tests/module_registry_spec.rb
|
306
309
|
- spec/unit_tests/resolve_dependencies_spec.rb
|
@@ -347,6 +350,8 @@ test_files:
|
|
347
350
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.xml
|
348
351
|
- spec/unit_tests/fixtures/files/Job-Multi-Project.yaml
|
349
352
|
- spec/unit_tests/fixtures/files/project.yaml
|
353
|
+
- spec/unit_tests/fixtures/templates/external_job.yaml
|
354
|
+
- spec/unit_tests/fixtures/templates/project_with_jobs.yaml
|
350
355
|
- spec/unit_tests/generator_spec.rb
|
351
356
|
- spec/unit_tests/module_registry_spec.rb
|
352
357
|
- spec/unit_tests/resolve_dependencies_spec.rb
|