lobot 1.0.pre → 2.0.0pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +0 -1
- data/Guardfile +10 -0
- data/README.md +52 -72
- data/Rakefile +2 -6
- data/Vagrantfile +15 -0
- data/bin/lobot +7 -0
- data/chef/cookbooks/pivotal_ci/.gitignore +4 -0
- data/chef/cookbooks/pivotal_ci/Gemfile +3 -0
- data/chef/cookbooks/pivotal_ci/README.md +3 -0
- data/chef/cookbooks/pivotal_ci/attributes/git.rb +1 -1
- data/chef/cookbooks/pivotal_ci/attributes/jenkins.rb +2 -3
- data/chef/cookbooks/pivotal_ci/attributes/nginx.rb +1 -2
- data/chef/cookbooks/pivotal_ci/attributes/ssl.rb +1 -1
- data/chef/cookbooks/pivotal_ci/files/default/tests/minitest/default_test.rb +37 -0
- data/chef/cookbooks/pivotal_ci/metadata.rb +10 -0
- data/chef/cookbooks/pivotal_ci/recipes/id_rsa.rb +5 -2
- data/chef/cookbooks/pivotal_ci/recipes/jenkins.rb +1 -1
- data/chef/cookbooks/pivotal_ci/recipes/jenkins_config.rb +10 -17
- data/chef/cookbooks/pivotal_ci/recipes/nginx.rb +2 -0
- data/chef/cookbooks/pivotal_ci/templates/default/jenkins-job-config.xml.erb +11 -3
- data/chef/cookbooks/pivotal_ci/templates/default/nginx-htaccess.erb +3 -3
- data/chef/cookbooks/pivotal_ci/templates/default/org.jenkinsci.plugins.xvfb.XvfbBuildWrapper.xml.erb +11 -0
- data/chef/cookbooks/pivotal_ci/test/kitchen/Kitchenfile +4 -0
- data/chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/attributes/default.rb +3 -0
- data/chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/metadata.rb +10 -0
- data/chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/recipes/default.rb +41 -0
- data/lib/generators/lobot/templates/soloistrc +2 -1
- data/lib/lobot.rb +1 -12
- data/lib/lobot/amazon.rb +91 -0
- data/lib/lobot/cli.rb +148 -0
- data/lib/lobot/config.rb +80 -0
- data/lib/lobot/jenkins.rb +17 -0
- data/lib/lobot/sobo.rb +35 -0
- data/lib/lobot/tasks/ci.rake +0 -178
- data/lib/lobot/version.rb +1 -1
- data/lobot.gemspec +19 -15
- data/script/bootstrap_server.sh +4 -1
- data/spec/lib/lobot/amazon_spec.rb +127 -0
- data/spec/lib/lobot/cli_spec.rb +212 -0
- data/spec/lib/lobot/config_spec.rb +95 -0
- data/spec/lib/lobot/jenkins_spec.rb +14 -0
- data/spec/spec_helper.rb +5 -10
- metadata +87 -31
- data/chef/cookbooks/pivotal_ci/libraries/ci_config.rb +0 -2
- data/spec/install_spec.rb +0 -80
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gem "builder", "~> 3.0.0" # Bundler goes into an infinite loop looking for this dep. Feel free to remove.
|
4
|
-
gem "rvm-capistrano", :group => :development, :require => false
|
5
4
|
|
6
5
|
# Specify your gem's dependencies in lobot.gemspec
|
7
6
|
gemspec
|
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
guard 'rspec', cli: '--fail-fast --tag ~@slow:true' do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
|
+
watch('spec/spec_helper.rb') { "spec" }
|
5
|
+
end
|
6
|
+
|
7
|
+
guard 'bundler' do
|
8
|
+
watch('Gemfile')
|
9
|
+
watch('lobot.gemspec')
|
10
|
+
end
|
data/README.md
CHANGED
@@ -9,108 +9,88 @@ Lando Calrissian relies on Lobot to keep Cloud City afloat, and now you can rely
|
|
9
9
|
|
10
10
|
# What do I get?
|
11
11
|
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
12
|
+
* Commands for creating, starting, stopping, or destroying your CI server on EC2
|
13
|
+
* The full [Travis CI](http://travis-ci.org) environment on Ubuntu 12.04
|
14
|
+
* A Jenkins frontend for monitoring your builds
|
15
15
|
|
16
|
-
After you add lobot to your Gemfile, all you'll need to do is run the following commands:
|
16
|
+
After you add `gem "lobot"` to your Gemfile, all you'll need to do is run the following commands:
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
[lobot configure] - COMING SOON - See Setup for now.
|
19
|
+
lobot create
|
20
|
+
lobot bootstrap
|
21
|
+
lobot add_build BobTheBuild git@github.com:you/some_repo.git master script/ci_build.sh
|
22
|
+
lobot chef
|
23
23
|
|
24
24
|
Read on for an explanation of what each one of these steps does.
|
25
25
|
|
26
26
|
## Install
|
27
27
|
|
28
|
-
Add lobot to your Gemfile, in the
|
28
|
+
Add lobot to your Gemfile, in the development group:
|
29
29
|
|
30
|
-
gem "lobot", :group => :
|
31
|
-
|
32
|
-
### To Install
|
33
|
-
|
34
|
-
rails g lobot:install
|
30
|
+
gem "lobot", :group => :development
|
35
31
|
|
36
32
|
## Setup
|
37
|
-
You can use a generator to interactively generate the config/ci.yml that includes some reasonable defaults and explanations.
|
38
|
-
|
39
|
-
rails g lobot:config
|
40
33
|
|
41
|
-
|
34
|
+
Create a config/lobot.yml file in your project:
|
42
35
|
|
43
36
|
---
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
name: run 'rake ci:create_server to populate'
|
55
|
-
instance_id: run 'rake ci:create_server to populate'
|
56
|
-
build_command: ./script/ci_build.sh
|
57
|
-
ec2_server_access:
|
58
|
-
key_pair_name: myapp_ci
|
59
|
-
id_rsa_path: ~/.ssh/id_rsa
|
60
|
-
github_private_ssh_key_path: ~/.ssh/id_rsa
|
37
|
+
server_ssh_key: ~/.ssh/id_rsa
|
38
|
+
github_ssh_key: ~/.ssh/id_rsa
|
39
|
+
aws_key: <your AWS Key>
|
40
|
+
aws_secret: <your AWS Secret>
|
41
|
+
node_attributes:
|
42
|
+
nginx:
|
43
|
+
basic_auth_user: ci
|
44
|
+
basic_auth_password: password
|
45
|
+
|
46
|
+
See [https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key](https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key) to generate AWS key/secret.
|
61
47
|
|
62
48
|
## Adjust Defaults (Optional)
|
63
|
-
|
49
|
+
|
50
|
+
In your config/lobot.yml, there are defaults set for values that have the recommened value. For example, the instance size used for EC2 is set to "c1.medium".
|
51
|
+
|
64
52
|
You can save on EC2 costs by using a tool like [projectmonitor](https://github.com/pivotal/projectmonitor) or ylastic to schedule when your instances are online.
|
65
53
|
|
66
54
|
## Commit and push your changes
|
67
55
|
|
68
56
|
At this point you will need to create a commit of the files generated or modified and push those changes to your remote git repository so Jenkins can execute the build script when it pulls down your repo for the first time.
|
69
57
|
|
70
|
-
|
58
|
+
If you must, you can do this on a branch. Then later you can change the branch in lobot.yml later and rechef.
|
59
|
+
|
60
|
+
## Modify recipe list
|
61
|
+
|
62
|
+
You can modify the chef run list by setting the `recipes` key in config/lobot.yml. The default is:
|
63
|
+
|
64
|
+
["pivotal_ci::jenkins", "pivotal_ci::limited_travis_ci_environment", "pivotal_ci"]`
|
71
65
|
|
72
|
-
|
66
|
+
Because we're using the cookbooks from Travis CI, you can look through [all the recipes Travis has available](https://github.com/travis-ci/travis-cookbooks/), and add any that you need.
|
73
67
|
|
74
68
|
## Starting your lobot instance
|
75
69
|
|
76
|
-
1. Launch an instance, allocate and associates an elastic IP and updates
|
70
|
+
1. Launch an instance, allocate and associates an elastic IP and updates config/lobot.yml:
|
77
71
|
|
78
|
-
|
72
|
+
lobot create
|
79
73
|
|
80
|
-
2. Bootstrap the instance using the boostrap_server.sh script
|
74
|
+
2. Bootstrap the instance using the boostrap_server.sh script. The script installs ruby prerequisites and installs RVM:
|
81
75
|
|
82
|
-
|
76
|
+
lobot bootstrap
|
83
77
|
|
84
|
-
3. Upload the contents of
|
78
|
+
3. Upload the contents of Lobot's cookbooks, create a soloistrc, and run chef:
|
85
79
|
|
86
|
-
|
80
|
+
lobot chef
|
87
81
|
|
88
82
|
Your lobot instance should now be up and running. You will be able to access your CI server at: http://<your instance address>/ with the username and password you chose during configuration.
|
89
|
-
For more information about Jenkins CI, see http://jenkins-ci.org
|
83
|
+
For more information about Jenkins CI, see [http://jenkins-ci.org](http://jenkins-ci.org).
|
90
84
|
|
91
85
|
## Troubleshooting
|
92
86
|
|
93
87
|
Shell access for your instance
|
94
88
|
|
95
|
-
|
89
|
+
lobot ssh
|
96
90
|
|
97
|
-
|
91
|
+
Terminate all Lobot instances on your account and deallocate their elastic IPs
|
98
92
|
|
99
|
-
|
100
|
-
|
101
|
-
Suspending your instance
|
102
|
-
|
103
|
-
rake ci:stop_server
|
104
|
-
|
105
|
-
Rstarting a server
|
106
|
-
|
107
|
-
rake ci:start_server
|
108
|
-
|
109
|
-
## Add your new CI instance to [projectmonitor](http://github.com/pivotal/projectmonitor) and CCMenu
|
110
|
-
|
111
|
-
Lobot can generate the config for you, just run:
|
112
|
-
|
113
|
-
rake ci:info
|
93
|
+
lobot destroy_ec2
|
114
94
|
|
115
95
|
## Color
|
116
96
|
|
@@ -125,17 +105,17 @@ end
|
|
125
105
|
## Dependencies
|
126
106
|
|
127
107
|
* fog
|
128
|
-
*
|
129
|
-
*
|
130
|
-
*
|
131
|
-
*
|
108
|
+
* ci_reporter
|
109
|
+
* thor
|
110
|
+
* hashie
|
111
|
+
* net-ssh
|
112
|
+
|
113
|
+
## Testing
|
132
114
|
|
133
|
-
|
115
|
+
Lobot is tested using rspec, vagrant and test kitchen. You will need to set environment variables with your AWS credentials to run tests which rely on ec2:
|
134
116
|
|
135
|
-
|
136
|
-
|
137
|
-
It will attempt to terminate the server however you should verify this so you do not get charged additional money.
|
138
|
-
Use the secrets.yml.example to create a secrets.yml file with your account information.
|
117
|
+
export EC2_KEY=FOO
|
118
|
+
export EC2_SECRET=BAR
|
139
119
|
|
140
120
|
# Contributing
|
141
121
|
|
data/Rakefile
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'ci/reporter/rake/rspec'
|
2
|
-
require 'ci/reporter/rake/cucumber'
|
3
2
|
require 'rspec/core/rake_task'
|
4
|
-
require 'cucumber/rake/task'
|
5
3
|
require 'bundler'
|
4
|
+
|
6
5
|
Bundler::GemHelper.install_tasks
|
7
6
|
|
8
|
-
task :default => ['ci:setup:rspec', :spec
|
7
|
+
task :default => ['ci:setup:rspec', :spec]
|
9
8
|
|
10
9
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
11
10
|
RSpec::Core::RakeTask.new(:spec)
|
12
11
|
|
13
|
-
desc "Run all features in the features directory"
|
14
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
15
|
-
end
|
data/Vagrantfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Vagrant::Config.run do |config|
|
2
|
+
config.vm.box = "precise64"
|
3
|
+
config.vm.box_url = "http://files.vagrantup.com/#{config.vm.box}.box"
|
4
|
+
config.vm.network :hostonly, "192.168.33.10"
|
5
|
+
|
6
|
+
config.vm.provision :shell, :inline => "sudo mkdir /etc/skel/.ssh"
|
7
|
+
|
8
|
+
config.vm.provision :shell do |shell|
|
9
|
+
shell.inline = "echo $@ | sudo tee /etc/skel/.ssh/authorized_keys"
|
10
|
+
ssh_key = ENV['LOBOT_SSH_KEY'] || File.expand_path("~/.ssh/id_rsa.pub")
|
11
|
+
shell.args = File.read(ssh_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
config.vm.provision :shell, :inline => "sudo useradd -m ubuntu -G sudo,admin -s /bin/bash"
|
15
|
+
end
|
data/bin/lobot
ADDED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
}
|
1
|
+
default["jenkins"] = {}
|
2
|
+
default["jenkins"]["home"] = "/var/lib/jenkins"
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
node["nginx_settings"]["basic_auth_users"] = CI_CONFIG['basic_auth']
|
1
|
+
default["nginx"] ||= {}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
describe_recipe "pivotal_ci::jenkins" do
|
2
|
+
include MiniTest::Chef::Assertions
|
3
|
+
include MiniTest::Chef::Context
|
4
|
+
include MiniTest::Chef::Resources
|
5
|
+
|
6
|
+
it "runs jenkins" do
|
7
|
+
service("jenkins").must_be_running
|
8
|
+
end
|
9
|
+
|
10
|
+
it "creates the jenkins user" do
|
11
|
+
user("jenkins").must_exist
|
12
|
+
end
|
13
|
+
|
14
|
+
it "configures the xvfb plugin" do
|
15
|
+
file("/var/lib/jenkins/org.jenkinsci.plugins.xvfb.XvfbBuildWrapper.xml").must_exist
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe_recipe "pivotal_ci::default" do
|
20
|
+
def wait_for(match, options="")
|
21
|
+
Timeout.timeout(10) do
|
22
|
+
sleep 1 until `curl #{options} -ks https://localhost/` =~ match
|
23
|
+
true
|
24
|
+
end
|
25
|
+
rescue Timeout::Error
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
it "requires basic auth" do
|
30
|
+
wait_for(/401 Authorization Required/).must_equal true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets the right basic_auth credentials" do
|
34
|
+
credentials = "#{node['nginx']['basic_auth_user']}:#{node['nginx']['basic_auth_password']}"
|
35
|
+
wait_for(/jenkins/, "--user #{credentials}").must_equal true
|
36
|
+
end
|
37
|
+
end
|
@@ -8,12 +8,15 @@ directory "#{node["jenkins"]["home"]}/.ssh" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
execute "copy id_rsa" do
|
11
|
-
|
11
|
+
destination_path = "#{node["jenkins"]["home"]}/.ssh/id_rsa"
|
12
|
+
source_path = "/home/#{username}/.ssh/id_rsa"
|
13
|
+
files = "#{source_path} #{destination_path}"
|
12
14
|
command "cp #{files}"
|
13
|
-
|
15
|
+
only_if { (::File.exists?(source_path)) && !system("diff -q #{files}") }
|
14
16
|
end
|
15
17
|
|
16
18
|
file "#{node["jenkins"]["home"]}/.ssh/id_rsa" do
|
19
|
+
mode 0600
|
17
20
|
owner "jenkins"
|
18
21
|
end
|
19
22
|
|
@@ -15,38 +15,31 @@ execute "download lobot plugin" do
|
|
15
15
|
jenkins_plugin.call(self, "lobot", "http://cheffiles.pivotallabs.com/lobot/lobot.hpi")
|
16
16
|
end
|
17
17
|
|
18
|
-
['git', 'ansicolor'].each do |plugin|
|
18
|
+
['git', 'ansicolor', 'xvfb'].each do |plugin|
|
19
19
|
execute "download #{plugin} plugin" do
|
20
20
|
jenkins_plugin.call(self, plugin, "http://mirrors.jenkins-ci.org/plugins/#{plugin}/latest/#{plugin}.hpi")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
template "#{node["jenkins"]["home"]}/jobs/#{ENV['APP_NAME']}/config.xml" do
|
29
|
-
source "jenkins-job-config.xml.erb"
|
24
|
+
template "#{node["jenkins"]["home"]}/org.jenkinsci.plugins.xvfb.XvfbBuildWrapper.xml" do
|
25
|
+
source "org.jenkinsci.plugins.xvfb.XvfbBuildWrapper.xml.erb"
|
30
26
|
owner "jenkins"
|
31
27
|
notifies :restart, "service[jenkins]"
|
32
|
-
variables(
|
33
|
-
:git_location => CI_CONFIG['git_location'],
|
34
|
-
:build_command => CI_CONFIG['build_command']
|
35
|
-
)
|
36
28
|
end
|
37
29
|
|
38
|
-
|
39
|
-
directory "#{node["jenkins"]["home"]}/jobs/#{build['
|
30
|
+
node["jenkins"]["builds"].each do |build|
|
31
|
+
directory "#{node["jenkins"]["home"]}/jobs/#{build['name']}" do
|
40
32
|
owner "jenkins"
|
41
33
|
end
|
42
34
|
|
43
|
-
template "#{node["jenkins"]["home"]}/jobs/#{build['
|
35
|
+
template "#{node["jenkins"]["home"]}/jobs/#{build['name']}/config.xml" do
|
44
36
|
source "jenkins-job-config.xml.erb"
|
45
37
|
owner "jenkins"
|
46
38
|
notifies :restart, "service[jenkins]"
|
47
39
|
variables(
|
48
|
-
:
|
49
|
-
:
|
40
|
+
:branch => build['branch'],
|
41
|
+
:command => build['command'],
|
42
|
+
:repository => build['repository']
|
50
43
|
)
|
51
44
|
end
|
52
|
-
end
|
45
|
+
end
|
@@ -10,12 +10,12 @@
|
|
10
10
|
<hudson.plugins.git.UserRemoteConfig>
|
11
11
|
<name></name>
|
12
12
|
<refspec></refspec>
|
13
|
-
<url><%= @
|
13
|
+
<url><%= @repository %></url>
|
14
14
|
</hudson.plugins.git.UserRemoteConfig>
|
15
15
|
</userRemoteConfigs>
|
16
16
|
<branches>
|
17
17
|
<hudson.plugins.git.BranchSpec>
|
18
|
-
<name
|
18
|
+
<name><%= @branch %></name>
|
19
19
|
</hudson.plugins.git.BranchSpec>
|
20
20
|
</branches>
|
21
21
|
<disableSubmodules>false</disableSubmodules>
|
@@ -51,7 +51,7 @@
|
|
51
51
|
<concurrentBuild>false</concurrentBuild>
|
52
52
|
<builders>
|
53
53
|
<hudson.tasks.Shell>
|
54
|
-
<command><%= @
|
54
|
+
<command><%= @command %></command>
|
55
55
|
</hudson.tasks.Shell>
|
56
56
|
</builders>
|
57
57
|
<publishers>
|
@@ -65,5 +65,13 @@
|
|
65
65
|
<hudson.plugins.ansicolor.AnsiColorBuildWrapper>
|
66
66
|
<colorMapName>xterm</colorMapName>
|
67
67
|
</hudson.plugins.ansicolor.AnsiColorBuildWrapper>
|
68
|
+
<org.jenkinsci.plugins.xvfb.XvfbBuildWrapper plugin="xvfb@1.0.4">
|
69
|
+
<installationName>system</installationName>
|
70
|
+
<screen>1024x768x24</screen>
|
71
|
+
<debug>false</debug>
|
72
|
+
<timeout>0</timeout>
|
73
|
+
<displayNameOffset>0</displayNameOffset>
|
74
|
+
<additionalOptions></additionalOptions>
|
75
|
+
</org.jenkinsci.plugins.xvfb.XvfbBuildWrapper>
|
68
76
|
</buildWrappers>
|
69
77
|
</project>
|