Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
igormoochnick committed Mar 5, 2014
1 parent 79e3659 commit e39c954
Show file tree
Hide file tree
Showing 46 changed files with 2,959 additions and 1 deletion.
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jenkins_pipeline_builder
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.0.0-p247
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

# Specify your gem's dependencies in jenkins_pipeline_builder.gemspec
gemspec
134 changes: 133 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,136 @@
jenkins-pipeline-builder
========================

YAML driven CI pipeline generator enabling to version your artifact pipelines alongside with the artifact source itself.
YAML driven CI Jenkins Pipeline Builder enabling to version your artifact pipelines alongside with the artifact source itself.


# JenkinsPipeline::Generator

TODO: Write a gem description

This is how you can bootstrap a pipeline:

generate pipeline -d -c config/login.yml bootstrap ./pipeline-archetype

## Installation

Add this line to your application's Gemfile:

gem 'jenkins_pipeline_builder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jenkins_pipeline_builder

brew install libxml2 libxslt
[optional] brew link libxml2 libxslt
gem install nokogiri

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## Job DSL
Here's a high level overview of what's available:

```yaml
- job:
name: nameStr # Name of your Job
job_type: free_style # Optional [free_style|multi_project]
parameters:
- name: param_name
type: string
default: default value
description: text
scm_provider: git # See more info on Jenkins Api Client
scm_url: [email protected]:your_url_here
scm_branch: master
scm_params:
excuded_users: user
local_branch: branch_name
recursive_update: true
wipe_workspace: true
shell_command: '. commit_build.sh'
hipchat:
room: room name here
start-notify: true
builders:
- job_builder:
child_jobs:
- job-name-1
- job-name-2
mark_phase: SUCCESSFUL
- inject_vars_file: build_job_info
- shell_command: |
echo 'Doing some work'
run command1
- maven3:
goals: -B clean
wrappers:
- timestamp: true
- ansicolor: true
- artifactory:
url: 'https://url.com/path'
artifactory-name: 'key'
target-repo: gems-local
publish: 'pkg/*.gem'
publish-build-info: true
- inject_env_var: |
VAR1 = value_1
VAR2 = value_2
- inject_passwords:
- name: pwd_name
value: some_encrypted_password
- rvm: "ruby-version@ruby-gemset"
publishers:
- junit_result:
test_results: 'out/**/*.xml'
- git:
push-merge: true
push-only-if-success: false
- hipchat:
jenkinsUrl: 'https://jenkins_url/'
authToken: 'auth_token'
room: 'room name'
- coverage_result:
report_dir: out/coverage/rcov
total:
healthy: 80
unhealthy: 0
unstable: 0
code:
healthy: 80
unhealthy: 0
unstable: 0
- description_setter:
regexp: See the build details at (.*)
description: 'Build Details: <a href="\1">\1</a>'
- downstream:
project: project_name
data:
- params: |
PARAM1=value1
PARAM2=value2
- file: promote-job-params
triggers:
- git_push: true
- scm_polling: 'H/5 * * * *'
build_flow: |
guard {
build("job_name1", param1: params["param1"]);
} rescue {
build("job_name2", param1: build21.environment.get("some_var"))
}
```
68 changes: 68 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# Copyright (c) 2014 Igor Moochnick
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

#!/usr/bin/env rake
require 'rspec/core/rake_task'
require 'yard'

RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args|
t.pattern = ".spec/**/*_spec.rb"
t.verbose = true
t.fail_on_error = false
t.rspec_opts = spec_output 'spec.xml'
end

def spec_output(filename)
"--color --format documentation --format RspecJunitFormatter --out out/#{filename}"
end

RSpec::Core::RakeTask.new(:unit_tests) do |spec|
spec.pattern = FileList['spec/unit_tests/*_spec.rb']
spec.rspec_opts = ['--color', '--format documentation']
end

RSpec::Core::RakeTask.new(:func_tests) do |spec|
spec.pattern = FileList['spec/func_tests/*_spec.rb']
spec.rspec_opts = ['--color', '--format documentation']
end

RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = FileList['spec/*/*.rb']
spec.rspec_opts = ['--color', '--format documentation']
end

YARD::Config.load_plugin 'thor'
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb', 'lib/**/**/*.rb']
end

namespace :doc do
# This task requires that graphviz is installed locally. For more info:
# http://www.graphviz.org/
desc "Generates the class diagram using the yard generated dot file"
task :generate_class_diagram do
puts "Generating the dot file..."
`yard graph --file jenkins_api_client.dot`
puts "Generating class diagram from the dot file..."
`dot jenkins_api_client.dot -Tpng -o jenkins_api_client_class_diagram.png`
end
end
28 changes: 28 additions & 0 deletions bin/generate
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2014 Igor Moochnick
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'jenksin_pipeline_builder'
JenkinsPipelineBuilder::CLI::Base.start

24 changes: 24 additions & 0 deletions config/login.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The Jenkins server and login information can be stored in a YAML file like this
# so we don't have to pass in the parameters every we login to the server
# through this API client.

# This file contains the following four parameters

# The IP address of the Jenkins CI Server

:server_ip: server_ip
#:server_url: https://server_url/

# The port number on which the Jenkins listens on. The default is 8080

#:server_port: 8080

# If there is a web server routing your Jenkins requests you might need this

#:jenkins_path: ""

# The username and password to authenticate to the server

:username: username
#:password: my_password
:password_base64: my_base64_password
42 changes: 42 additions & 0 deletions jenkins_pipeline_builder.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jenksin_pipeline_builder/version'

Gem::Specification.new do |spec|
spec.name = 'jenkins_pipeline_builder'
spec.version = JenkinsPipelineBuilder::VERSION
spec.authors = ['Igor Moochnick']
spec.email = %w([email protected])
spec.description = %q{This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
automating Job & Pipeline creation from the YAML files checked-in with your application source code}
spec.summary = %q{This gem is will boostrap your Jenkins pipelines}
spec.homepage = 'https://github.com/IgorShare/jenkins_pipeline_builder'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES']='true'

spec.add_dependency 'nokogiri', '~> 1.5.0'
spec.add_dependency 'jenkins_api_client', '~> 0.14.1'
spec.add_dependency 'thor', '>= 0.18.0'

spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 2.14'
spec.add_development_dependency 'bump'
spec.add_development_dependency 'gem-release'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'simplecov-rcov'
spec.add_development_dependency 'kwalify'
spec.add_development_dependency 'equivalent-xml'
spec.add_development_dependency 'yard-thor'
spec.add_development_dependency 'yard'
spec.add_development_dependency 'rspec_junit_formatter'
spec.add_development_dependency 'webmock'
end
39 changes: 39 additions & 0 deletions lib/jenksin_pipeline_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (c) 2014 Igor Moochnick
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

require 'jenksin_pipeline_builder/version'
require 'jenksin_pipeline_builder/utils'
require 'jenksin_pipeline_builder/xml_helper'
require 'jenksin_pipeline_builder/compiler'
require 'jenksin_pipeline_builder/job_builder'
require 'jenksin_pipeline_builder/module_registry'
require 'jenksin_pipeline_builder/builders'
require 'jenksin_pipeline_builder/wrappers'
require 'jenksin_pipeline_builder/triggers'
require 'jenksin_pipeline_builder/publishers'
require 'jenksin_pipeline_builder/view'
require 'jenksin_pipeline_builder/generator'

require 'jenksin_pipeline_builder/cli/helper'
require 'jenksin_pipeline_builder/cli/view'
require 'jenksin_pipeline_builder/cli/pipeline'
require 'jenksin_pipeline_builder/cli/base'
Loading

0 comments on commit e39c954

Please sign in to comment.