winci 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in winci.gemspec
4
+ gemspec
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2011-04-23
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,6 @@
1
+
2
+ You should take a look at WinCI-server which is intended to be used with this gem.
3
+
4
+ For more information on WinCI, see http://winci.rubyforge.org
5
+
6
+
@@ -0,0 +1,61 @@
1
+ winci
2
+ ======
3
+
4
+ [WinCI] Simplifies mplementation of a full continuous deployment pipeline the Agile way with Jenkins/Hudson continuous integration server under Windows.
5
+
6
+ Install
7
+ =======
8
+
9
+ gem install winci
10
+
11
+
12
+ Introduction
13
+ =======
14
+
15
+ The purpose of this project is to simplify implementation of the full continuous deployment pipeline the Agile way with Jenkins/Hudson continuous integration server under Windows.
16
+ It will let Windows developers get quickly up and running with continuous deployment pipeline and
17
+ continuous integration by incorporating convention-over-configuration paradigm, so that the novice is first presented with
18
+ working setup with the click of a button and after he see it working and have overall empirical knowledge under his belt,
19
+ only then is he introduced to some configuration options.
20
+
21
+ WinCI is written in Ruby and uses Jenkins.rb gem to automate installation and interaction with Jenkins CI and also ruby-git gem to automate CI provisioning.
22
+
23
+ WinCI is intended to be be used in conjunction with WinCI-server, which is another gem containing functionality necessary
24
+ to setup Jenkins CI and enabling to create installation bundle used in provisioning process.
25
+
26
+
27
+ Usage
28
+ =====
29
+
30
+ First download and run WinCI-server.
31
+ Then you can start using this gem, first take a look at examples directory.
32
+ Keep in mind that so far this project is mostly a wrapper for functionality contained in Jenkins.rb gem,
33
+ so if you would like to create nodes in Jenkins or create rake build steps then you should look at Jenkins.rb gem's docs or API file.
34
+
35
+
36
+
37
+ License
38
+ =======
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2011 Kamil Sobieraj, ksob\at\rubyforge.org
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,19 @@
1
+ require 'jenkins'
2
+ require 'winci'
3
+
4
+ project_name = 'files'
5
+
6
+ cfg = Jenkins::JobConfigBuilder.new(:ruby) do |c|
7
+ c.scm = "C:/repos/#{project_name}.git"
8
+ c.steps = [
9
+ # below makes sense when your Rakefile run rspec/cucumber by default
10
+ [:build_bat_step, "bundle exec rake"],
11
+ # this will send current code to production repo only after rspec/cucumber passed
12
+ [:build_bat_step, "git push c:/repos/production/files.git HEAD:master"]
13
+ ]
14
+ end
15
+
16
+ job = WinCI::Job.new project_name, cfg
17
+
18
+ # by default creates job on localhost:3010
19
+ job.create
@@ -0,0 +1,24 @@
1
+ require 'jenkins'
2
+ require 'winci'
3
+
4
+ project_name = 'files'
5
+
6
+ cfg = Jenkins::JobConfigBuilder.new(:ruby) do |c|
7
+ c.scm = "C:/repos/#{project_name}.git"
8
+ c.steps = [
9
+ # in this way we can ensure that the PATH is the same as in production environment
10
+ [:build_shell_step, "export PATH=C:/Ruby/bin;\r\n" + "echo PATH is now : $PATH"],
11
+ # then we can run some installation script
12
+ [:build_bat_step, "ruby install.rb"],
13
+ # see basic.rb
14
+ [:build_bat_step, "bundle exec rake"],
15
+ # some adjustments to git before pushing
16
+ [:build_bat_step, "git config core.hidedotfiles false"],
17
+ # see basic.rb
18
+ [:build_bat_step, "git push c:/repos/production/files.git HEAD:master"]
19
+ ]
20
+ end
21
+
22
+ job = WinCI::Job.new project_name, cfg
23
+
24
+ job.create '192.168.1.10', '3010'
@@ -0,0 +1,8 @@
1
+ require 'winci'
2
+
3
+ project_name = 'files'
4
+
5
+ job = WinCI::Job.new project_name
6
+
7
+ puts job.last_successful_build
8
+ puts job.last_successful_build_sha
@@ -0,0 +1,5 @@
1
+ module WinCI
2
+ require 'winci/version'
3
+ require 'winci/job'
4
+ require 'winci/build'
5
+ end
@@ -0,0 +1,9 @@
1
+ module Jenkins
2
+ class JobConfigBuilder
3
+ def build_bat_step(b, command)
4
+ b.tag! "hudson.tasks.BatchFile" do
5
+ b.command command.to_xs.gsub("&", '&')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,60 @@
1
+ require 'fileutils'
2
+ require 'jenkins'
3
+ require 'winci/jenkins_ext/job_config_builder'
4
+
5
+ module WinCI
6
+
7
+ class Job
8
+ attr_accessor :project_name, :config
9
+
10
+ def initialize(project_name='files', config=std_config)
11
+ @project_name = project_name
12
+ @config = config
13
+ end
14
+
15
+ def std_config
16
+ Jenkins::JobConfigBuilder.new(:ruby) do |c|
17
+ c.scm = "C:/repos/files.git"
18
+ c.steps = [
19
+ [:build_bat_step, "bundle exec rake"],
20
+ [:build_bat_step, "git push C:/repos/production/files.git HEAD:master"]
21
+ ]
22
+ end
23
+ end
24
+
25
+
26
+ def create server='127.0.0.1', port='3010'
27
+ Jenkins::Api.setup_base_url(:host => server, :port => port)
28
+
29
+ if Jenkins::Api.create_job(name=@project_name, @config, options = {:override => true}) == true
30
+ puts "#{@project_name} project created on jenkins"
31
+ else
32
+ puts "#{@project_name} project not created, something gone wrong or it already exist"
33
+ end
34
+ end
35
+
36
+ def last_successful_build
37
+ Jenkins::Api.job(@project_name)["lastSuccessfulBuild"]
38
+ end
39
+
40
+ def get_build_sha build
41
+ # Retrieve information about the actual build, and grab the last built revision out of it
42
+ build_info = Jenkins::Api.get("/job/#{@project_name}/#{build["number"]}/api/json")
43
+ build_info['actions'].detect { |h| h["lastBuiltRevision"] }["lastBuiltRevision"]["SHA1"]
44
+ end
45
+
46
+ def last_successful_build_sha
47
+ if last_successful_build
48
+ return get_build_sha last_successful_build
49
+ else
50
+ raise 'There is none successful build yet!'
51
+ end
52
+ end
53
+
54
+ def provide_build(build=last_successful_build_sha, environments=['production'])
55
+ # TODO provide this build to selected environments
56
+ end
57
+
58
+ end
59
+ end
60
+
@@ -0,0 +1,10 @@
1
+ Rake::TaskManager.class_eval do
2
+ def remove_task(task_name)
3
+ @tasks.delete(task_name.to_s)
4
+ end
5
+ end
6
+
7
+ def remove_task(task_name)
8
+ Rake.application.remove_task(task_name)
9
+ end
10
+
@@ -0,0 +1,3 @@
1
+ module WinCI
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "winci/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "winci"
7
+ s.version = WinCI::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Kamil Sobieraj"]
10
+ s.email = ["ksob@rubyforge.org"]
11
+ s.homepage = ""
12
+ s.summary = %q{Simplifies continuous integration under Windows}
13
+ s.description = %q{Implements full continuous deployment pipeline the Agile way with Jenkins/Hudson continuous integration server under Windows.}
14
+
15
+ s.rubyforge_project = "winci"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency('jenkins', '>= 0.6.2')
23
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: winci
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Kamil Sobieraj
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-30 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: jenkins
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ - 6
33
+ - 2
34
+ version: 0.6.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Implements full continuous deployment pipeline the Agile way with Jenkins/Hudson continuous integration server under Windows.
38
+ email:
39
+ - ksob@rubyforge.org
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - History.txt
50
+ - PostInstall.txt
51
+ - README.txt
52
+ - Rakefile
53
+ - examples/basic.rb
54
+ - examples/extended.rb
55
+ - examples/retrieving_info.rb
56
+ - lib/winci.rb
57
+ - lib/winci/jenkins_ext/job_config_builder.rb
58
+ - lib/winci/job.rb
59
+ - lib/winci/tasks.rb
60
+ - lib/winci/version.rb
61
+ - winci.gemspec
62
+ has_rdoc: true
63
+ homepage: ""
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project: winci
92
+ rubygems_version: 1.5.2
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Simplifies continuous integration under Windows
96
+ test_files: []
97
+