jenkins-maestrodev 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog.md +58 -0
  3. data/Gemfile +3 -0
  4. data/README.md +162 -0
  5. data/Rakefile +110 -0
  6. data/bin/jenkins +9 -0
  7. data/cucumber.yml +8 -0
  8. data/features/build_details.feature +44 -0
  9. data/features/configure.feature +36 -0
  10. data/features/default_host.feature +26 -0
  11. data/features/development.feature +14 -0
  12. data/features/listing_jobs.feature +34 -0
  13. data/features/manage_jobs.feature +263 -0
  14. data/features/manage_slave_nodes.feature +83 -0
  15. data/features/step_definitions/common_steps.rb +192 -0
  16. data/features/step_definitions/fixture_project_steps.rb +8 -0
  17. data/features/step_definitions/jenkins_steps.rb +116 -0
  18. data/features/step_definitions/scm_steps.rb +12 -0
  19. data/features/support/common.rb +37 -0
  20. data/features/support/env.rb +19 -0
  21. data/features/support/hooks.rb +16 -0
  22. data/features/support/jenkins_helpers.rb +6 -0
  23. data/features/support/matchers.rb +10 -0
  24. data/fixtures/jenkins/envfile.hpi +0 -0
  25. data/fixtures/jenkins/git.hpi +0 -0
  26. data/fixtures/jenkins/github.hpi +0 -0
  27. data/fixtures/jenkins/greenballs.hpi +0 -0
  28. data/fixtures/jenkins/rake.hpi +0 -0
  29. data/fixtures/jenkins/ruby.hpi +0 -0
  30. data/fixtures/projects/erlang/rebar.config +1 -0
  31. data/fixtures/projects/non-bundler/Rakefile +4 -0
  32. data/fixtures/projects/rails-3/.gitignore +4 -0
  33. data/fixtures/projects/rails-3/Gemfile +30 -0
  34. data/fixtures/projects/rails-3/Gemfile.lock +74 -0
  35. data/fixtures/projects/rails-3/README +256 -0
  36. data/fixtures/projects/rails-3/Rakefile +7 -0
  37. data/fixtures/projects/rails-3/app/controllers/application_controller.rb +3 -0
  38. data/fixtures/projects/rails-3/app/helpers/application_helper.rb +2 -0
  39. data/fixtures/projects/rails-3/app/views/layouts/application.html.erb +14 -0
  40. data/fixtures/projects/rails-3/config.ru +4 -0
  41. data/fixtures/projects/rails-3/config/application.rb +42 -0
  42. data/fixtures/projects/rails-3/config/boot.rb +13 -0
  43. data/fixtures/projects/rails-3/config/database.yml +22 -0
  44. data/fixtures/projects/rails-3/config/environment.rb +5 -0
  45. data/fixtures/projects/rails-3/config/environments/development.rb +26 -0
  46. data/fixtures/projects/rails-3/config/environments/production.rb +49 -0
  47. data/fixtures/projects/rails-3/config/environments/test.rb +35 -0
  48. data/fixtures/projects/rails-3/config/initializers/backtrace_silencers.rb +7 -0
  49. data/fixtures/projects/rails-3/config/initializers/inflections.rb +10 -0
  50. data/fixtures/projects/rails-3/config/initializers/mime_types.rb +5 -0
  51. data/fixtures/projects/rails-3/config/initializers/secret_token.rb +7 -0
  52. data/fixtures/projects/rails-3/config/initializers/session_store.rb +8 -0
  53. data/fixtures/projects/rails-3/config/locales/en.yml +5 -0
  54. data/fixtures/projects/rails-3/config/routes.rb +58 -0
  55. data/fixtures/projects/rails-3/db/seeds.rb +7 -0
  56. data/fixtures/projects/rails-3/doc/README_FOR_APP +2 -0
  57. data/fixtures/projects/rails-3/lib/tasks/.gitkeep +0 -0
  58. data/fixtures/projects/rails-3/public/404.html +26 -0
  59. data/fixtures/projects/rails-3/public/422.html +26 -0
  60. data/fixtures/projects/rails-3/public/500.html +26 -0
  61. data/fixtures/projects/rails-3/public/favicon.ico +0 -0
  62. data/fixtures/projects/rails-3/public/images/rails.png +0 -0
  63. data/fixtures/projects/rails-3/public/index.html +239 -0
  64. data/fixtures/projects/rails-3/public/javascripts/application.js +2 -0
  65. data/fixtures/projects/rails-3/public/javascripts/controls.js +965 -0
  66. data/fixtures/projects/rails-3/public/javascripts/dragdrop.js +974 -0
  67. data/fixtures/projects/rails-3/public/javascripts/effects.js +1123 -0
  68. data/fixtures/projects/rails-3/public/javascripts/prototype.js +6001 -0
  69. data/fixtures/projects/rails-3/public/javascripts/rails.js +175 -0
  70. data/fixtures/projects/rails-3/public/robots.txt +5 -0
  71. data/fixtures/projects/rails-3/public/stylesheets/.gitkeep +0 -0
  72. data/fixtures/projects/rails-3/script/rails +6 -0
  73. data/fixtures/projects/rails-3/test/performance/browsing_test.rb +9 -0
  74. data/fixtures/projects/rails-3/test/test_helper.rb +13 -0
  75. data/fixtures/projects/rails-3/vendor/plugins/.gitkeep +0 -0
  76. data/fixtures/projects/ruby/Gemfile +3 -0
  77. data/fixtures/projects/ruby/Gemfile.lock +10 -0
  78. data/fixtures/projects/ruby/Rakefile +4 -0
  79. data/jenkins.gemspec +34 -0
  80. data/lib/jenkins.rb +6 -0
  81. data/lib/jenkins/api.rb +312 -0
  82. data/lib/jenkins/cli.rb +361 -0
  83. data/lib/jenkins/cli/formatting.rb +53 -0
  84. data/lib/jenkins/config.rb +27 -0
  85. data/lib/jenkins/core_ext/hash.rb +9 -0
  86. data/lib/jenkins/core_ext/object/blank.rb +77 -0
  87. data/lib/jenkins/hudson-cli.jar +0 -0
  88. data/lib/jenkins/job_config_builder.rb +417 -0
  89. data/lib/jenkins/project_scm.rb +22 -0
  90. data/lib/jenkins/remote.rb +11 -0
  91. data/lib/jenkins/version.rb +3 -0
  92. data/spec/api_spec.rb +67 -0
  93. data/spec/fixtures/ec2_global.config.xml +103 -0
  94. data/spec/fixtures/erlang.single.config.xml +59 -0
  95. data/spec/fixtures/rails.multi.config.xml +82 -0
  96. data/spec/fixtures/rails.single.config.triggers.xml +84 -0
  97. data/spec/fixtures/rails.single.config.xml +80 -0
  98. data/spec/fixtures/ruby.multi-ruby-multi-labels.config.xml +84 -0
  99. data/spec/fixtures/ruby.multi.config.xml +77 -0
  100. data/spec/fixtures/ruby.single.config.xml +58 -0
  101. data/spec/fixtures/ruby.user-defined-axis.config.xml +69 -0
  102. data/spec/fixtures/therubyracer.config.xml +77 -0
  103. data/spec/hash_key_cleaner_spec.rb +25 -0
  104. data/spec/job_config_builder_spec.rb +233 -0
  105. data/spec/spec_helper.rb +15 -0
  106. metadata +291 -0
@@ -0,0 +1,84 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <matrix-project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.plugins.git.GitSCM">
8
+ <configVersion>1</configVersion>
9
+ <remoteRepositories>
10
+ <org.spearce.jgit.transport.RemoteConfig>
11
+ <string>origin</string>
12
+ <int>5</int>
13
+ <string>fetch</string>
14
+ <string>+refs/heads/*:refs/remotes/origin/*</string>
15
+ <string>receivepack</string>
16
+ <string>git-upload-pack</string>
17
+ <string>uploadpack</string>
18
+ <string>git-upload-pack</string>
19
+ <string>url</string>
20
+ <string>http://github.com/drnic/picasa_plucker.git</string>
21
+ <string>tagopt</string>
22
+ <string/>
23
+ </org.spearce.jgit.transport.RemoteConfig>
24
+ </remoteRepositories>
25
+ <branches>
26
+ <hudson.plugins.git.BranchSpec>
27
+ <name>master</name>
28
+ </hudson.plugins.git.BranchSpec>
29
+ </branches>
30
+ <localBranch/>
31
+ <mergeOptions/>
32
+ <recursiveSubmodules>false</recursiveSubmodules>
33
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
34
+ <authorOrCommitter>false</authorOrCommitter>
35
+ <clean>false</clean>
36
+ <wipeOutWorkspace>false</wipeOutWorkspace>
37
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
38
+ <gitTool>Default</gitTool>
39
+ <submoduleCfg class="list"/>
40
+ <relativeTargetDir/>
41
+ <excludedRegions/>
42
+ <excludedUsers/>
43
+ </scm>
44
+ <canRoam>true</canRoam>
45
+ <disabled>false</disabled>
46
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
47
+ <triggers class="vector"/>
48
+ <concurrentBuild>false</concurrentBuild>
49
+ <axes>
50
+ <hudson.matrix.TextAxis>
51
+ <name>RUBY_VERSION</name>
52
+ <values>
53
+ <string>1.8.7</string>
54
+ <string>1.9.2</string>
55
+ <string>rbx-head</string>
56
+ <string>jruby</string>
57
+ </values>
58
+ </hudson.matrix.TextAxis>
59
+ <hudson.matrix.LabelAxis>
60
+ <name>label</name>
61
+ <values>
62
+ <string>1.8.7</string>
63
+ <string>ubuntu</string>
64
+ </values>
65
+ </hudson.matrix.LabelAxis>
66
+ </axes>
67
+ <builders>
68
+ <hudson.tasks.Shell>
69
+ <command>rvm $RUBY_VERSION</command>
70
+ </hudson.tasks.Shell>
71
+ <hudson.tasks.Shell>
72
+ <command>rvm gemset create ruby-$RUBY_VERSION &amp;&amp; rvm gemset use ruby-$RUBY_VERSION</command>
73
+ </hudson.tasks.Shell>
74
+ <hudson.tasks.Shell>
75
+ <command>bundle install</command>
76
+ </hudson.tasks.Shell>
77
+ <hudson.tasks.Shell>
78
+ <command>bundle exec rake</command>
79
+ </hudson.tasks.Shell>
80
+ </builders>
81
+ <publishers/>
82
+ <buildWrappers/>
83
+ <runSequentially>false</runSequentially>
84
+ </matrix-project>
@@ -0,0 +1,77 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <matrix-project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.plugins.git.GitSCM">
8
+ <configVersion>1</configVersion>
9
+ <remoteRepositories>
10
+ <org.spearce.jgit.transport.RemoteConfig>
11
+ <string>origin</string>
12
+ <int>5</int>
13
+ <string>fetch</string>
14
+ <string>+refs/heads/*:refs/remotes/origin/*</string>
15
+ <string>receivepack</string>
16
+ <string>git-upload-pack</string>
17
+ <string>uploadpack</string>
18
+ <string>git-upload-pack</string>
19
+ <string>url</string>
20
+ <string>http://github.com/drnic/picasa_plucker.git</string>
21
+ <string>tagopt</string>
22
+ <string/>
23
+ </org.spearce.jgit.transport.RemoteConfig>
24
+ </remoteRepositories>
25
+ <branches>
26
+ <hudson.plugins.git.BranchSpec>
27
+ <name>master</name>
28
+ </hudson.plugins.git.BranchSpec>
29
+ </branches>
30
+ <localBranch/>
31
+ <mergeOptions/>
32
+ <recursiveSubmodules>false</recursiveSubmodules>
33
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
34
+ <authorOrCommitter>false</authorOrCommitter>
35
+ <clean>false</clean>
36
+ <wipeOutWorkspace>false</wipeOutWorkspace>
37
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
38
+ <gitTool>Default</gitTool>
39
+ <submoduleCfg class="list"/>
40
+ <relativeTargetDir/>
41
+ <excludedRegions/>
42
+ <excludedUsers/>
43
+ </scm>
44
+ <canRoam>true</canRoam>
45
+ <disabled>false</disabled>
46
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
47
+ <triggers class="vector"/>
48
+ <concurrentBuild>false</concurrentBuild>
49
+ <axes>
50
+ <hudson.matrix.TextAxis>
51
+ <name>RUBY_VERSION</name>
52
+ <values>
53
+ <string>1.8.7</string>
54
+ <string>1.9.2</string>
55
+ <string>rbx-head</string>
56
+ <string>jruby</string>
57
+ </values>
58
+ </hudson.matrix.TextAxis>
59
+ </axes>
60
+ <builders>
61
+ <hudson.tasks.Shell>
62
+ <command>rvm $RUBY_VERSION</command>
63
+ </hudson.tasks.Shell>
64
+ <hudson.tasks.Shell>
65
+ <command>rvm gemset create ruby-$RUBY_VERSION &amp;&amp; rvm gemset use ruby-$RUBY_VERSION</command>
66
+ </hudson.tasks.Shell>
67
+ <hudson.tasks.Shell>
68
+ <command>bundle install</command>
69
+ </hudson.tasks.Shell>
70
+ <hudson.tasks.Shell>
71
+ <command>bundle exec rake</command>
72
+ </hudson.tasks.Shell>
73
+ </builders>
74
+ <publishers/>
75
+ <buildWrappers/>
76
+ <runSequentially>false</runSequentially>
77
+ </matrix-project>
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.plugins.git.GitSCM">
8
+ <configVersion>1</configVersion>
9
+ <remoteRepositories>
10
+ <org.spearce.jgit.transport.RemoteConfig>
11
+ <string>origin</string>
12
+ <int>5</int>
13
+ <string>fetch</string>
14
+ <string>+refs/heads/*:refs/remotes/origin/*</string>
15
+ <string>receivepack</string>
16
+ <string>git-upload-pack</string>
17
+ <string>uploadpack</string>
18
+ <string>git-upload-pack</string>
19
+ <string>url</string>
20
+ <string>git://codebasehq.com/mocra/misc/mocra-web.git</string>
21
+ <string>tagopt</string>
22
+ <string/>
23
+ </org.spearce.jgit.transport.RemoteConfig>
24
+ </remoteRepositories>
25
+ <branches>
26
+ <hudson.plugins.git.BranchSpec>
27
+ <name>master</name>
28
+ </hudson.plugins.git.BranchSpec>
29
+ </branches>
30
+ <localBranch/>
31
+ <mergeOptions/>
32
+ <recursiveSubmodules>false</recursiveSubmodules>
33
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
34
+ <authorOrCommitter>false</authorOrCommitter>
35
+ <clean>false</clean>
36
+ <wipeOutWorkspace>false</wipeOutWorkspace>
37
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
38
+ <gitTool>Default</gitTool>
39
+ <submoduleCfg class="list"/>
40
+ <relativeTargetDir/>
41
+ <excludedRegions/>
42
+ <excludedUsers/>
43
+ </scm>
44
+ <canRoam>true</canRoam>
45
+ <disabled>false</disabled>
46
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
47
+ <concurrentBuild>false</concurrentBuild>
48
+ <builders>
49
+ <hudson.tasks.Shell>
50
+ <command>bundle install</command>
51
+ </hudson.tasks.Shell>
52
+ <hudson.tasks.Shell>
53
+ <command>bundle exec rake</command>
54
+ </hudson.tasks.Shell>
55
+ </builders>
56
+ <publishers/>
57
+ <buildWrappers/>
58
+ </project>
@@ -0,0 +1,69 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <matrix-project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.plugins.git.GitSCM">
8
+ <configVersion>1</configVersion>
9
+ <remoteRepositories>
10
+ <org.spearce.jgit.transport.RemoteConfig>
11
+ <string>origin</string>
12
+ <int>5</int>
13
+ <string>fetch</string>
14
+ <string>+refs/heads/*:refs/remotes/origin/*</string>
15
+ <string>receivepack</string>
16
+ <string>git-upload-pack</string>
17
+ <string>uploadpack</string>
18
+ <string>git-upload-pack</string>
19
+ <string>url</string>
20
+ <string>http://github.com/drnic/picasa_plucker.git</string>
21
+ <string>tagopt</string>
22
+ <string/>
23
+ </org.spearce.jgit.transport.RemoteConfig>
24
+ </remoteRepositories>
25
+ <branches>
26
+ <hudson.plugins.git.BranchSpec>
27
+ <name>master</name>
28
+ </hudson.plugins.git.BranchSpec>
29
+ </branches>
30
+ <localBranch/>
31
+ <mergeOptions/>
32
+ <recursiveSubmodules>false</recursiveSubmodules>
33
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
34
+ <authorOrCommitter>false</authorOrCommitter>
35
+ <clean>false</clean>
36
+ <wipeOutWorkspace>false</wipeOutWorkspace>
37
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
38
+ <gitTool>Default</gitTool>
39
+ <submoduleCfg class="list"/>
40
+ <relativeTargetDir/>
41
+ <excludedRegions/>
42
+ <excludedUsers/>
43
+ </scm>
44
+ <canRoam>true</canRoam>
45
+ <disabled>false</disabled>
46
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
47
+ <triggers class="vector"/>
48
+ <concurrentBuild>false</concurrentBuild>
49
+ <axes>
50
+ <hudson.matrix.TextAxis>
51
+ <name>user_defined_axis</name>
52
+ <values>
53
+ <string>custom_value_1</string>
54
+ <string>custom_value_2</string>
55
+ </values>
56
+ </hudson.matrix.TextAxis>
57
+ </axes>
58
+ <builders>
59
+ <hudson.tasks.Shell>
60
+ <command>bundle install</command>
61
+ </hudson.tasks.Shell>
62
+ <hudson.tasks.Shell>
63
+ <command>bundle exec rake</command>
64
+ </hudson.tasks.Shell>
65
+ </builders>
66
+ <publishers/>
67
+ <buildWrappers/>
68
+ <runSequentially>false</runSequentially>
69
+ </matrix-project>
@@ -0,0 +1,77 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <matrix-project>
3
+ <actions/>
4
+ <description></description>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.plugins.git.GitSCM">
8
+ <configVersion>1</configVersion>
9
+ <remoteRepositories>
10
+ <org.spearce.jgit.transport.RemoteConfig>
11
+ <string>origin</string>
12
+ <int>5</int>
13
+ <string>fetch</string>
14
+ <string>+refs/heads/*:refs/remotes/origin/*</string>
15
+ <string>receivepack</string>
16
+ <string>git-upload-pack</string>
17
+ <string>uploadpack</string>
18
+ <string>git-upload-pack</string>
19
+ <string>url</string>
20
+ <string>git://github.com/cowboyd/therubyracer.git</string>
21
+ <string>tagopt</string>
22
+ <string></string>
23
+ </org.spearce.jgit.transport.RemoteConfig>
24
+ </remoteRepositories>
25
+ <branches>
26
+ <hudson.plugins.git.BranchSpec>
27
+ <name>master</name>
28
+ </hudson.plugins.git.BranchSpec>
29
+ </branches>
30
+ <mergeOptions/>
31
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
32
+ <clean>true</clean>
33
+ <choosingStrategy>Default</choosingStrategy>
34
+ <submoduleCfg class="list"/>
35
+ </scm>
36
+ <canRoam>true</canRoam>
37
+ <disabled>false</disabled>
38
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
39
+ <triggers class="vector"/>
40
+ <concurrentBuild>false</concurrentBuild>
41
+ <axes>
42
+ <axis>
43
+ <name>RUBY_VERSION</name>
44
+ <values>
45
+ <string>1.8.6</string>
46
+ <string>1.8.7</string>
47
+ <string>1.9.1</string>
48
+ </values>
49
+ </axis>
50
+ <axis>
51
+ <name>label</name>
52
+ <values>
53
+ <string>OSX-Leopard-10.5</string>
54
+ <string>Ubuntu-Lucid-10.04-server-amd64</string>
55
+ <string>Ubuntu-Karmic-9.10-server-amd64</string>
56
+ <string>OSX-Snow-Leopard-10.6.3</string>
57
+ </values>
58
+ </axis>
59
+ </axes>
60
+ <builders>
61
+ <hudson.tasks.Shell>
62
+ <command>#!/bin/bash -lxe
63
+ GEMSET=build-$BUILD_NUMBER-ruby-$RUBY_VERSION
64
+ rvm $RUBY_VERSION
65
+ rvm gemset create $GEMSET
66
+ rvm gemset use $GEMSET
67
+ gem install rake rake-compiler rspec
68
+ rake gem
69
+ gem install therubyracer-*.gem
70
+ v8 --selftest
71
+ </command>
72
+ </hudson.tasks.Shell>
73
+ </builders>
74
+ <publishers/>
75
+ <buildWrappers/>
76
+ <runSequentially>false</runSequentially>
77
+ </matrix-project>
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ require "jenkins/core_ext/hash"
4
+
5
+ describe Hash do
6
+ subject do
7
+ {
8
+ :simple => "simple",
9
+ :under_score => "under_score",
10
+ :"hyp-hen" => "hyphen",
11
+ "str_under_score" => "str_under_score",
12
+ "str-hyp-hen" => "str-hyp-hen"
13
+ }
14
+ end
15
+
16
+ it do
17
+ subject.with_clean_keys.should == {
18
+ :simple => "simple",
19
+ :under_score => "under_score",
20
+ :hyp_hen => "hyphen",
21
+ :str_under_score => "str_under_score",
22
+ :str_hyp_hen => "str-hyp-hen"
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,233 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe Jenkins::JobConfigBuilder do
4
+ include ConfigFixtureLoaders
5
+
6
+ describe "explicit steps to match a ruby job" do
7
+ before do
8
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
9
+ c.scm = "git://codebasehq.com/mocra/misc/mocra-web.git"
10
+ c.steps = [
11
+ [:build_shell_step, "step 1"],
12
+ [:build_shell_step, "step 2"]
13
+ ]
14
+ end
15
+ end
16
+ it "builds config.xml" do
17
+ steps = Hpricot.XML(@config.to_xml).search("command")
18
+ steps.map(&:inner_text).should == ["step 1", "step 2"]
19
+ end
20
+ end
21
+
22
+ describe "rails job; single axis" do
23
+ before do
24
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
25
+ c.scm = "git://codebasehq.com/mocra/misc/mocra-web.git"
26
+ end
27
+ end
28
+ it "builds config.xml" do
29
+ config_xml("rails", "single").should == @config.to_xml
30
+ end
31
+ end
32
+
33
+ describe "many rubies" do
34
+ before do
35
+ @config = Jenkins::JobConfigBuilder.new(:ruby) do |c|
36
+ c.scm = "http://github.com/drnic/picasa_plucker.git"
37
+ c.rubies = %w[1.8.7 1.9.2 rbx-head jruby]
38
+ end
39
+ end
40
+ it "have have explicit rubies" do
41
+ config_xml("ruby", "multi").should == @config.to_xml
42
+ end
43
+
44
+ it "and many labels/assigned_nodes" do
45
+ @config.node_labels = %w[1.8.7 ubuntu]
46
+ config_xml("ruby", "multi-ruby-multi-labels").should == @config.to_xml
47
+ end
48
+ end
49
+
50
+ describe "user-defined axes" do
51
+
52
+ it "have user-defined axes" do
53
+ @config = Jenkins::JobConfigBuilder.new(:ruby) do |c|
54
+ c.scm = "http://github.com/drnic/picasa_plucker.git"
55
+ c.user_axes =[ { :name => 'user_defined_axis', :values => ["custom_value_1", "custom_value_2"] } ]
56
+ end
57
+ config_xml("ruby", "user-defined-axis").should == @config.to_xml
58
+ end
59
+ end
60
+
61
+ describe "assigned slave nodes for slave usage" do
62
+ before do
63
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
64
+ c.assigned_node = "my-slave"
65
+ end
66
+ end
67
+ it "builds config.xml" do
68
+ Hpricot.XML(@config.to_xml).search("assignedNode").size.should == 1
69
+ Hpricot.XML(@config.to_xml).search("assignedNode").text.should == "my-slave"
70
+ Hpricot.XML(@config.to_xml).search("canRoam").text.should == "false"
71
+ end
72
+ end
73
+
74
+ describe "no specific slave nodes" do
75
+ before do
76
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
77
+ end
78
+ end
79
+ it "builds config.xml" do
80
+ Hpricot.XML(@config.to_xml).search("assignedNode").size.should == 0
81
+ end
82
+ end
83
+
84
+ describe "SCM behaviour" do
85
+ describe "#public_scm = true => convert git@ into git:// until we have deploy keys" do
86
+ before do
87
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
88
+ c.scm = "git@codebasehq.com:mocra/misc/mocra-web.git"
89
+ c.public_scm = true
90
+ end
91
+ end
92
+ it "builds config.xml" do
93
+ config_xml("rails", "single").should == @config.to_xml
94
+ end
95
+ end
96
+
97
+ # <branches>
98
+ # <hudson.plugins.git.BranchSpec>
99
+ # <name>master</name>
100
+ # </hudson.plugins.git.BranchSpec>
101
+ # <hudson.plugins.git.BranchSpec>
102
+ # <name>other</name>
103
+ # </hudson.plugins.git.BranchSpec>
104
+ # </branches>
105
+ describe "#scm-branches - set branches" do
106
+ before do
107
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
108
+ c.scm = "git@codebasehq.com:mocra/misc/mocra-web.git"
109
+ end
110
+ end
111
+ it "defaults to 'master'" do
112
+ branch_names = Hpricot.XML(@config.to_xml).search("branches name")
113
+ branch_names.size.should == 1
114
+ branch_names.text.should == "master"
115
+ branch_names.first.parent.name.should == "hudson.plugins.git.BranchSpec"
116
+ end
117
+ it "can have specific branches" do
118
+ branches = @config.scm_branches = %w[master other branches]
119
+ branch_names = Hpricot.XML(@config.to_xml).search("branches name")
120
+ branch_names.size.should == 3
121
+ branch_names.map(&:inner_text).should == branches
122
+ end
123
+ end
124
+ end
125
+
126
+ describe "setup ENV variables via envfile plugin" do
127
+ before do
128
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
129
+ c.scm = "git://codebasehq.com/mocra/misc/mocra-web.git"
130
+ c.steps = []
131
+ c.envfile = "/path/to/env/file"
132
+ end
133
+ end
134
+ it "builds config.xml" do
135
+ xml_bite = <<-XML.gsub(/^ /, '')
136
+ <buildWrappers>
137
+ <hudson.plugins.envfile.EnvFileBuildWrapper>
138
+ <filePath>/path/to/env/file</filePath>
139
+ </hudson.plugins.envfile.EnvFileBuildWrapper>
140
+ </buildWrappers>
141
+ XML
142
+ Hpricot.XML(@config.to_xml).search("buildWrappers").to_s.should == xml_bite.strip
143
+ end
144
+ end
145
+
146
+ describe "setup log rotator" do
147
+ before do
148
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
149
+ c.log_rotate = { :days_to_keep => 14 }
150
+ end
151
+ end
152
+
153
+ it 'builds config.xml' do
154
+ xml_bite = <<-XML.gsub(/^ /, '')
155
+ <logRotator>
156
+ <daysToKeep>14</daysToKeep>
157
+ <numToKeep>-1</numToKeep>
158
+ <artifactDaysToKeep>-1</artifactDaysToKeep>
159
+ <artifactNumToKeep>-1</artifactNumToKeep>
160
+ </logRotator>
161
+ XML
162
+ Hpricot.XML(@config.to_xml).search("logRotator").to_s.should == xml_bite.strip
163
+ end
164
+ end
165
+
166
+ describe "setup build triggers" do
167
+ before do
168
+ @config = Jenkins::JobConfigBuilder.new(:rails) do |c|
169
+ c.triggers = [{:class => :timer, :spec => "5 * * * *"}]
170
+ end
171
+ end
172
+
173
+ it 'builds config.xml' do
174
+ xml_bite = <<-XML.gsub(/^ /, '')
175
+ <triggers class="vector">
176
+ <hudson.triggers.TimerTrigger>
177
+ <spec>5 * * * *</spec>
178
+ </hudson.triggers.TimerTrigger>
179
+ </triggers>
180
+ XML
181
+ Hpricot.XML(@config.to_xml).search("triggers").to_s.should == xml_bite.strip
182
+ end
183
+ end
184
+
185
+ describe "setup publishers for a build" do
186
+ before do
187
+ @config = Jenkins::JobConfigBuilder.new(:none) do |c|
188
+ c.publishers = [
189
+ { :chuck_norris => true },
190
+ { :job_triggers => { :projects => ["Dependent Job", "Even more dependent job"], :on => "FAILURE" } },
191
+ { :mailer => ["some.guy@example.com", "another.guy@example.com"] }
192
+ ]
193
+ end
194
+ end
195
+
196
+ it 'builds config.xml' do
197
+ xml_bite = <<-XML.gsub(/^ /, '')
198
+ <publishers>
199
+ <hudson.plugins.chucknorris.CordellWalkerRecorder>
200
+ <factGenerator />
201
+ </hudson.plugins.chucknorris.CordellWalkerRecorder>
202
+ <hudson.tasks.BuildTrigger>
203
+ <childProjects>Dependent Job, Even more dependent job</childProjects>
204
+ <threshold>
205
+ <name>FAILURE</name>
206
+ <ordinal>2</ordinal>
207
+ <color>RED</color>
208
+ </threshold>
209
+ </hudson.tasks.BuildTrigger>
210
+ <hudson.tasks.Mailer>
211
+ <recipients>some.guy@example.com, another.guy@example.com</recipients>
212
+ <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
213
+ <sendToIndividuals>true</sendToIndividuals>
214
+ </hudson.tasks.Mailer>
215
+ </publishers>
216
+ XML
217
+ Hpricot.XML(@config.to_xml).search("publishers").to_s.should == xml_bite.strip
218
+ end
219
+ end
220
+
221
+ describe "erlang job; single axis" do
222
+ before do
223
+ @config = Jenkins::JobConfigBuilder.new(:erlang) do |c|
224
+ c.scm = "git://codebasehq.com/mocra/misc/mocra-web.git"
225
+ end
226
+ end
227
+ it "builds config.xml" do
228
+ config_xml("erlang", "single").should == @config.to_xml
229
+ end
230
+ end
231
+
232
+
233
+ end