`compare_versions': undefined method `[]' for nil:NilClass (NoMethodError)

42 views
Skip to first unread message

Ashish Sharma

unread,
Aug 15, 2014, 7:18:18 PM8/15/14
to jenkins_a...@googlegroups.com
Hello,

I am new to ruby and to this gem.

trying to automate some jenkins builds, so i wrote up a quick script to launch a demo job. The job works fine on my test jenkins server, but is failing with the subject error on the production one.

I can see the job is being triggered, so its probably something when querying for status or something. Jenkins version is 1.532.2.2 (Jenkins Enterprise by CloudBees 13.11)

Here is the script

require 'jenkins_api_client'
begin
@client = JenkinsApi::Client.new(:server_url => 'http://prod_jenkins:8080/jenkins/job/Teams/job/MyTeam/',
:username=> ARGV[0],
:password=> ARGV[1],
:log_level=> Logger::DEBUG
)

puts @client.job.list_all
puts @client.get_jenkins_version
puts "Starting job sequence"
completed=false

on_progress = lambda do |max,curr,count|
puts " maxwait #{max} current_wait #{curr} current_count #{count}" 
end
on_completed = lambda do |build_number,cancelled|
puts "done build #{build_number} cancelled #{cancelled}"
completed = true
 end
opts = {'build_start_timeout' => 300,
'cancel_on_build_start_timeout' => true,
'progress_proc' => on_progress ,
'completion_proc' => on_completed
}
@client.job.build("script_test_job", {}, opts)
puts "Job launched, waiting now"
sleep 2 until completed
end

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jenkins_api_client-1.0.1/lib/jenkins_api_client/client.rb:534:in `compare_versions': undefined method `[]' for nil:NilClass (NoMethodError)
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jenkins_api_client-1.0.1/lib/jenkins_api_client/job.rb:792:in `build'
        from C:/gitdev/TestAndTrials/jenkins_demo/launch_dev_jenins.rb:29:in `<main>'


Kannan Manickam

unread,
Aug 15, 2014, 8:20:32 PM8/15/14
to jenkins_a...@googlegroups.com
Ashish,

I think i know what the problem could be. I believe it is due to the version number having 4 parts in it. I'll look into that more later this weekend.

Ashish Sharma

unread,
Aug 18, 2014, 12:50:02 PM8/18/14
to jenkins_a...@googlegroups.com
Hi Kannan,

wondering if you got a chance to look into it ?

thanks
-ashish
Reply all
Reply to author
Forward
0 new messages