Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Remove a bad error message advertising an --xml output format
Browse files Browse the repository at this point in the history
Since Jenkins::Api is hitting the JSON API, there's no reasonable way to export
XML from the job details

This commit also includes a few whitespace and formatting fixes

Fixes #17
  • Loading branch information
R. Tyler Croy committed Jul 30, 2012
1 parent 32ef8ce commit b165bd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ruby-tools/cli/lib/jenkins/cli.rb
Expand Up @@ -166,7 +166,7 @@ def job(name)
require "yaml"
puts job.parsed_response.to_yaml
else
error "Select an output format: --json, --xml, --yaml, --hash"
error "Select an output format: --json, --yaml, --hash"
end
else
error "Cannot find project '#{name}'."
Expand Down
36 changes: 18 additions & 18 deletions ruby-tools/cli/lib/jenkins/job_config_builder.rb
Expand Up @@ -10,16 +10,16 @@ class JobConfigBuilder
attr_accessor :scm, :public_scm, :scm_branches
attr_accessor :assigned_node, :node_labels # TODO just one of these
attr_accessor :envfile

InvalidTemplate = Class.new(StandardError)

VALID_JOB_TEMPLATES = %w[none rails rails3 ruby rubygem erlang]
JOB_TRIGGER_THRESHOLDS = {
"SUCCESS" => {:ordinal => 0, :color => "BLUE"},
"UNSTABLE" => {:ordinal => 1, :color => "YELLOW"},
"FAILURE" => {:ordinal => 2, :color => "RED"}
}

# +job_type+ - template of default steps to create with the job
# +steps+ - array of [:method, cmd], e.g. [:build_shell_step, "bundle initial"]
# - Default is based on +job_type+.
Expand All @@ -33,13 +33,13 @@ class JobConfigBuilder
# +log_rotate+ - define log rotation
def initialize(job_type = :ruby, &block)
self.job_type = job_type.to_s if job_type

yield self

self.scm_branches ||= ["master"]
raise InvalidTemplate unless VALID_JOB_TEMPLATES.include?(job_type.to_s)
end

def builder
b = Builder::XmlMarkup.new :indent => 2
b.instruct!
Expand All @@ -63,13 +63,13 @@ def builder
b.runSequentially false if matrix_project?
end
end

def to_xml
builder.to_s
end

protected

# <scm class="hudson.plugins.git.GitSCM"> ... </scm>
def build_scm(b)
if scm && scm =~ /git/
Expand All @@ -92,7 +92,7 @@ def build_scm(b)
b.string
end
end

if scm_branches
b.branches do
scm_branches.each do |branch|
Expand All @@ -102,7 +102,7 @@ def build_scm(b)
end
end
end

b.localBranch
b.mergeOptions
b.recursiveSubmodules false
Expand All @@ -123,7 +123,7 @@ def build_scm(b)
def matrix_project?
!(rubies.blank? && node_labels.blank?)
end

# <hudson.matrix.TextAxis>
# <name>RUBY_VERSION</name>
# <values>
Expand Down Expand Up @@ -164,7 +164,7 @@ def build_axes(b)
end
end
end

# Example:
# <buildWrappers>
# <hudson.plugins.envfile.EnvFileBuildWrapper>
Expand Down Expand Up @@ -279,7 +279,7 @@ def build_publishers(b)
b.publishers
end
end

# The important sequence of steps that are run to process a job build.
# Can be defaulted by the +job_type+ using +default_steps(job_type)+,
# or customized via +steps+ array.
Expand All @@ -292,7 +292,7 @@ def build_steps(b)
end
end
end

def default_steps(job_type)
steps = case job_type.to_sym
when :rails, :rails3
Expand Down Expand Up @@ -331,14 +331,14 @@ def default_steps(job_type)
end
rubies.blank? ? steps : default_rvm_steps + steps
end

def default_rvm_steps
[
[:build_shell_step, "rvm $RUBY_VERSION"],
[:build_shell_step, "rvm gemset create ruby-$RUBY_VERSION && rvm gemset use ruby-$RUBY_VERSION"]
]
end

# <hudson.tasks.Shell>
# <command>echo &apos;THERE ARE NO STEPS! Except this one...&apos;</command>
# </hudson.tasks.Shell>
Expand All @@ -363,7 +363,7 @@ def build_ruby_step(b, command)
end
end
end

# Usage: build_ruby_step b, "db:schema:load"
#
# <hudson.plugins.rake.Rake>
Expand All @@ -384,7 +384,7 @@ def build_rake_step(b, tasks)
b.silent false
end
end

# Converts git@github.com:drnic/newgem.git into git://github.com/drnic/newgem.git
def public_only_git_scm(scm_url)
if scm_url =~ /git@([\w\-_.]+):(.+)\.git/
Expand Down
5 changes: 2 additions & 3 deletions ruby-tools/cli/spec/api_spec.rb
@@ -1,8 +1,7 @@
require File.dirname(__FILE__) + "/spec_helper"

describe Jenkins::Api do
context "#setup_base_url" do

describe "#setup_base_url" do
it "should accept a hash with a host and port as an argument" do
uri = Jenkins::Api.setup_base_url :host => 'hash.example.com', :port => '123'
uri.host.should == 'hash.example.com'
Expand Down Expand Up @@ -55,4 +54,4 @@
end
end
end
end
end

0 comments on commit b165bd6

Please sign in to comment.