jenkins_pipeline_builder 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Rakefile +68 -0
- data/bin/generate +28 -0
- data/config/login.yml +24 -0
- data/jenkins_pipeline_builder.gemspec +42 -0
- data/lib/jenksin_pipeline_builder.rb +39 -0
- data/lib/jenksin_pipeline_builder/builders.rb +72 -0
- data/lib/jenksin_pipeline_builder/cli/base.rb +69 -0
- data/lib/jenksin_pipeline_builder/cli/helper.rb +68 -0
- data/lib/jenksin_pipeline_builder/cli/pipeline.rb +40 -0
- data/lib/jenksin_pipeline_builder/cli/view.rb +40 -0
- data/lib/jenksin_pipeline_builder/compiler.rb +81 -0
- data/lib/jenksin_pipeline_builder/generator.rb +346 -0
- data/lib/jenksin_pipeline_builder/job_builder.rb +82 -0
- data/lib/jenksin_pipeline_builder/module_registry.rb +82 -0
- data/lib/jenksin_pipeline_builder/publishers.rb +113 -0
- data/lib/jenksin_pipeline_builder/triggers.rb +38 -0
- data/lib/jenksin_pipeline_builder/utils.rb +46 -0
- data/lib/jenksin_pipeline_builder/version.rb +25 -0
- data/lib/jenksin_pipeline_builder/view.rb +259 -0
- data/lib/jenksin_pipeline_builder/wrappers.rb +91 -0
- data/lib/jenksin_pipeline_builder/xml_helper.rb +40 -0
- data/spec/func_tests/spec_helper.rb +18 -0
- data/spec/func_tests/view_spec.rb +93 -0
- data/spec/unit_tests/compiler_spec.rb +19 -0
- data/spec/unit_tests/fixtures/files/Job-Build-Flow.xml +57 -0
- data/spec/unit_tests/fixtures/files/Job-Build-Flow.yaml +22 -0
- data/spec/unit_tests/fixtures/files/Job-Build-Maven.xml +90 -0
- data/spec/unit_tests/fixtures/files/Job-Build-Maven.yaml +26 -0
- data/spec/unit_tests/fixtures/files/Job-DSL.yaml +14 -0
- data/spec/unit_tests/fixtures/files/Job-DSL1.xml +27 -0
- data/spec/unit_tests/fixtures/files/Job-DSL2.xml +25 -0
- data/spec/unit_tests/fixtures/files/Job-Gem-Build.xml +142 -0
- data/spec/unit_tests/fixtures/files/Job-Gem-Build.yaml +41 -0
- data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.xml +32 -0
- data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml +8 -0
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.xml +117 -0
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.yaml +36 -0
- data/spec/unit_tests/fixtures/files/project.yaml +15 -0
- data/spec/unit_tests/generator_spec.rb +67 -0
- data/spec/unit_tests/module_registry_spec.rb +19 -0
- data/spec/unit_tests/resolve_dependencies_spec.rb +230 -0
- data/spec/unit_tests/spec_helper.rb +29 -0
- metadata +75 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ca15662c8969eb3344f177fcb31ab60d00d6b22
|
4
|
+
data.tar.gz: 8f65fdb0f74e18c8f301db3d7002fe842ca9f972
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 439d16077649cd6bcf6ab257c59ff1fe4703275a9eb25bbc43b4579ec867e579230761edbb30ef14420f32ab2bc4d0063e5c4e02555e000569242c83cb70dedd
|
7
|
+
data.tar.gz: 8f8f450ac270775f331038742d3c7390ae521339a4ef846197c1c8110a124f5d7e14565c5b2d2f959b39e9881d104a2a563ea895ba74371b135613167d89066a
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jenkins_pipeline_builder
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p247
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
#!/usr/bin/env rake
|
24
|
+
require 'rspec/core/rake_task'
|
25
|
+
require 'yard'
|
26
|
+
|
27
|
+
RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args|
|
28
|
+
t.pattern = ".spec/**/*_spec.rb"
|
29
|
+
t.verbose = true
|
30
|
+
t.fail_on_error = false
|
31
|
+
t.rspec_opts = spec_output 'spec.xml'
|
32
|
+
end
|
33
|
+
|
34
|
+
def spec_output(filename)
|
35
|
+
"--color --format documentation --format RspecJunitFormatter --out out/#{filename}"
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec::Core::RakeTask.new(:unit_tests) do |spec|
|
39
|
+
spec.pattern = FileList['spec/unit_tests/*_spec.rb']
|
40
|
+
spec.rspec_opts = ['--color', '--format documentation']
|
41
|
+
end
|
42
|
+
|
43
|
+
RSpec::Core::RakeTask.new(:func_tests) do |spec|
|
44
|
+
spec.pattern = FileList['spec/func_tests/*_spec.rb']
|
45
|
+
spec.rspec_opts = ['--color', '--format documentation']
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec::Core::RakeTask.new(:test) do |spec|
|
49
|
+
spec.pattern = FileList['spec/*/*.rb']
|
50
|
+
spec.rspec_opts = ['--color', '--format documentation']
|
51
|
+
end
|
52
|
+
|
53
|
+
YARD::Config.load_plugin 'thor'
|
54
|
+
YARD::Rake::YardocTask.new do |t|
|
55
|
+
t.files = ['lib/**/*.rb', 'lib/**/**/*.rb']
|
56
|
+
end
|
57
|
+
|
58
|
+
namespace :doc do
|
59
|
+
# This task requires that graphviz is installed locally. For more info:
|
60
|
+
# http://www.graphviz.org/
|
61
|
+
desc "Generates the class diagram using the yard generated dot file"
|
62
|
+
task :generate_class_diagram do
|
63
|
+
puts "Generating the dot file..."
|
64
|
+
`yard graph --file jenkins_api_client.dot`
|
65
|
+
puts "Generating class diagram from the dot file..."
|
66
|
+
`dot jenkins_api_client.dot -Tpng -o jenkins_api_client_class_diagram.png`
|
67
|
+
end
|
68
|
+
end
|
data/bin/generate
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
#!/usr/bin/env ruby
|
24
|
+
|
25
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
26
|
+
require 'jenksin_pipeline_builder'
|
27
|
+
JenkinsPipelineBuilder::CLI::Base.start
|
28
|
+
|
data/config/login.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# The Jenkins server and login information can be stored in a YAML file like this
|
2
|
+
# so we don't have to pass in the parameters every we login to the server
|
3
|
+
# through this API client.
|
4
|
+
|
5
|
+
# This file contains the following four parameters
|
6
|
+
|
7
|
+
# The IP address of the Jenkins CI Server
|
8
|
+
|
9
|
+
:server_ip: server_ip
|
10
|
+
#:server_url: https://server_url/
|
11
|
+
|
12
|
+
# The port number on which the Jenkins listens on. The default is 8080
|
13
|
+
|
14
|
+
#:server_port: 8080
|
15
|
+
|
16
|
+
# If there is a web server routing your Jenkins requests you might need this
|
17
|
+
|
18
|
+
#:jenkins_path: ""
|
19
|
+
|
20
|
+
# The username and password to authenticate to the server
|
21
|
+
|
22
|
+
:username: username
|
23
|
+
#:password: my_password
|
24
|
+
:password_base64: my_base64_password
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jenksin_pipeline_builder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jenkins_pipeline_builder'
|
8
|
+
spec.version = JenkinsPipelineBuilder::VERSION
|
9
|
+
spec.authors = ['Igor Moochnick']
|
10
|
+
spec.email = %w(igor.moochnick@gmail.com)
|
11
|
+
spec.description = %q{This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
|
12
|
+
automating Job & Pipeline creation from the YAML files checked-in with your application source code}
|
13
|
+
spec.summary = %q{This gem is will boostrap your Jenkins pipelines}
|
14
|
+
spec.homepage = 'https://github.com/IgorShare/jenkins_pipeline_builder'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES']='true'
|
23
|
+
|
24
|
+
spec.add_dependency 'nokogiri', '~> 1.5.0'
|
25
|
+
spec.add_dependency 'jenkins_api_client', '~> 0.14.1'
|
26
|
+
spec.add_dependency 'thor', '>= 0.18.0'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 2.14'
|
31
|
+
spec.add_development_dependency 'bump'
|
32
|
+
spec.add_development_dependency 'gem-release'
|
33
|
+
spec.add_development_dependency 'pry'
|
34
|
+
spec.add_development_dependency 'simplecov'
|
35
|
+
spec.add_development_dependency 'simplecov-rcov'
|
36
|
+
spec.add_development_dependency 'kwalify'
|
37
|
+
spec.add_development_dependency 'equivalent-xml'
|
38
|
+
spec.add_development_dependency 'yard-thor'
|
39
|
+
spec.add_development_dependency 'yard'
|
40
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
41
|
+
spec.add_development_dependency 'webmock'
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'jenksin_pipeline_builder/version'
|
24
|
+
require 'jenksin_pipeline_builder/utils'
|
25
|
+
require 'jenksin_pipeline_builder/xml_helper'
|
26
|
+
require 'jenksin_pipeline_builder/compiler'
|
27
|
+
require 'jenksin_pipeline_builder/job_builder'
|
28
|
+
require 'jenksin_pipeline_builder/module_registry'
|
29
|
+
require 'jenksin_pipeline_builder/builders'
|
30
|
+
require 'jenksin_pipeline_builder/wrappers'
|
31
|
+
require 'jenksin_pipeline_builder/triggers'
|
32
|
+
require 'jenksin_pipeline_builder/publishers'
|
33
|
+
require 'jenksin_pipeline_builder/view'
|
34
|
+
require 'jenksin_pipeline_builder/generator'
|
35
|
+
|
36
|
+
require 'jenksin_pipeline_builder/cli/helper'
|
37
|
+
require 'jenksin_pipeline_builder/cli/view'
|
38
|
+
require 'jenksin_pipeline_builder/cli/pipeline'
|
39
|
+
require 'jenksin_pipeline_builder/cli/base'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
module JenkinsPipelineBuilder
|
24
|
+
class Builders
|
25
|
+
def self.build_multijob_builder(params, xml)
|
26
|
+
xml.send('com.tikal.jenkins.plugins.multijob.MultiJobBuilder') {
|
27
|
+
xml.phaseName 'Child Jobs'
|
28
|
+
xml.phaseJobs {
|
29
|
+
proc = lambda do |xml, name|
|
30
|
+
xml.send('com.tikal.jenkins.plugins.multijob.PhaseJobsConfig') {
|
31
|
+
xml.jobName name
|
32
|
+
xml.currParams false
|
33
|
+
xml.exposedSCM false
|
34
|
+
xml.configs {
|
35
|
+
xml.send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') {
|
36
|
+
xml.properties 'PARENT_WORKSPACE=${WORKSPACE}'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
params[:child_jobs].each do |name|
|
42
|
+
proc.call xml, name
|
43
|
+
end
|
44
|
+
}
|
45
|
+
xml.continuationCondition params[:mark_phase]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.build_maven3(params, xml)
|
50
|
+
xml.send('org.jfrog.hudson.maven3.Maven3Builder') {
|
51
|
+
xml.mavenName 'tools-maven-3.0.3'
|
52
|
+
xml.rootPom params[:rootPom]
|
53
|
+
xml.goals params[:goals]
|
54
|
+
xml.mavenOpts params[:options]
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.build_shell_command(param, xml)
|
59
|
+
xml.send('hudson.tasks.Shell') {
|
60
|
+
xml.command param
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.build_environment_vars_injector(params, xml)
|
65
|
+
xml.EnvInjectBuilder {
|
66
|
+
xml.info {
|
67
|
+
xml.propertiesFilePath params
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'thor'
|
24
|
+
#require "#{File.dirname(__FILE__)}/pipeline.rb"
|
25
|
+
|
26
|
+
module JenkinsPipelineBuilder
|
27
|
+
module CLI
|
28
|
+
class Base < Thor
|
29
|
+
|
30
|
+
class_option :username, :aliases => "-u", :desc => "Name of Jenkins user"
|
31
|
+
class_option :password, :aliases => "-p",
|
32
|
+
:desc => "Password of Jenkins user"
|
33
|
+
class_option :password_base64, :aliases => "-b",
|
34
|
+
:desc => "Base 64 encoded password of Jenkins user"
|
35
|
+
class_option :server_ip, :aliases => "-s",
|
36
|
+
:desc => "Jenkins server IP address"
|
37
|
+
class_option :server_port, :aliases => "-o", :desc => "Jenkins port"
|
38
|
+
class_option :creds_file, :aliases => "-c",
|
39
|
+
:desc => "Credentials file for communicating with Jenkins server"
|
40
|
+
class_option :debug, :type => :boolean, :aliases => "-d", :desc => "Run in debug mode (no Jenkins changes)",
|
41
|
+
:default => false
|
42
|
+
|
43
|
+
|
44
|
+
map "-v" => :version
|
45
|
+
|
46
|
+
desc "version", "Shows current version"
|
47
|
+
# CLI command that returns the version of Jenkins API Client
|
48
|
+
def version
|
49
|
+
puts JenkinsPipelineBuilder::VERSION
|
50
|
+
end
|
51
|
+
|
52
|
+
# Register the CLI::Pipeline class as "pipeline" subcommand to CLI
|
53
|
+
register(
|
54
|
+
CLI::Pipeline,
|
55
|
+
'pipeline',
|
56
|
+
'pipeline [subcommand]',
|
57
|
+
'Provides functions to access pipeline functions of the Jenkins CI server'
|
58
|
+
)
|
59
|
+
|
60
|
+
# Register the CLI::Job class as "view" subcommand to CLI
|
61
|
+
register(
|
62
|
+
CLI::View,
|
63
|
+
'view',
|
64
|
+
'view [subcommand]',
|
65
|
+
'Provides functions to access view interface of Jenkins CI server'
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'fileutils'
|
24
|
+
require 'yaml'
|
25
|
+
require 'jenkins_api_client'
|
26
|
+
|
27
|
+
module JenkinsPipelineBuilder
|
28
|
+
module CLI
|
29
|
+
# This is the helper class that sets up the credentials from the command
|
30
|
+
# line parameters given and initializes the Jenkins Pipeline Builder.
|
31
|
+
class Helper
|
32
|
+
# Sets up the credentials and initializes the Jenkins Pipeline Builder
|
33
|
+
#
|
34
|
+
# @param [Hash] options Options obtained from the command line
|
35
|
+
#
|
36
|
+
# @return [JenkinsPipelineBuilder::Generator] A new Client object
|
37
|
+
#
|
38
|
+
def self.setup(options)
|
39
|
+
if options[:username] && options[:server_ip] && \
|
40
|
+
(options[:password] || options[:password_base64])
|
41
|
+
creds = options
|
42
|
+
elsif options[:creds_file]
|
43
|
+
creds = YAML.load_file(
|
44
|
+
#File.expand_path(options[:creds_file], __FILE__)
|
45
|
+
options[:creds_file]
|
46
|
+
)
|
47
|
+
elsif File.exist?("#{ENV['HOME']}/.jenkins_api_client/login.yml")
|
48
|
+
creds = YAML.load_file(
|
49
|
+
File.expand_path(
|
50
|
+
"#{ENV['HOME']}/.jenkins_api_client/login.yml", __FILE__
|
51
|
+
)
|
52
|
+
)
|
53
|
+
else
|
54
|
+
msg = "Credentials are not set. Please pass them as parameters or"
|
55
|
+
msg << " set them in the default credentials file"
|
56
|
+
puts msg
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
60
|
+
#creds[:log_level] = Logger::DEBUG
|
61
|
+
client = JenkinsApi::Client.new(creds)
|
62
|
+
generator = JenkinsPipelineBuilder::Generator.new(options, client)
|
63
|
+
generator.debug = options[:debug] #== 'debug'
|
64
|
+
return generator
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2014 Igor Moochnick
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
module JenkinsPipelineBuilder
|
24
|
+
module CLI
|
25
|
+
# This class provides various command line operations related to jobs.
|
26
|
+
class Pipeline < Thor
|
27
|
+
include Thor::Actions
|
28
|
+
|
29
|
+
desc 'dump', 'Dump job'
|
30
|
+
def dump(job_name)
|
31
|
+
Helper.setup(parent_options).dump(job_name)
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'bootstrap Path', 'Generates pipeline from folder or a file'
|
35
|
+
def bootstrap(path)
|
36
|
+
Helper.setup(parent_options).bootstrap(path)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|