Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create node #122

Merged

Conversation

loa
Copy link
Contributor

@loa loa commented Feb 6, 2014

Using LTS Jenkins ver. 1.532.1 installed by rpm on CentOS 6.4

jenkins_api_client.git on fa7a2ea

ruby scripts/login_with_irb.rb

puts @client.job.list(".*")

puts @client.node.create_dump_slave(
  :name => "slave1",
  :slave_host => "10.10.10.10",
  :private_key_file => "/root/.ssh/id_rsa",
  :executors => 10,
  :labels => "slave, ruby"
)
ruby scripts/login_with_irb.rb
logged-in to the Jenkins API, use the '@client' variable to use the client
irb(main):001:0> puts @client.job.list(".*")
I, [2014-02-06T15:18:16.314955 #47425]  INFO -- : Obtaining jobs matching filter '.*'
I, [2014-02-06T15:18:16.315061 #47425]  INFO -- : GET /api/json
whoami
=> nil
irb(main):002:0> puts @client.node.create_dump_slave(
irb(main):003:1*   :name => "slave1",
irb(main):004:1*   :slave_host => "10.10.10.10",
irb(main):005:1*   :private_key_file => "/root/.ssh/id_rsa",
irb(main):006:1*   :executors => 10,
irb(main):007:1*   :labels => "slave, ruby"
irb(main):008:1> )
I, [2014-02-06T15:18:22.079072 #47425]  INFO -- : Creating a dump slave 'slave1'
I, [2014-02-06T15:18:22.079319 #47425]  INFO -- : GET /api/json
I, [2014-02-06T15:18:22.085380 #47425]  INFO -- : POST /computer/doCreateItem
E, [2014-02-06T15:18:22.099554 #47425] ERROR -- : JenkinsApi::Exceptions::InternalServerError: Internel Server Error. Perhaps the in-memory configuration Jenkins is different from the disk configuration. Please try to reload the configuration
JenkinsApi::Exceptions::InternalServerError: Internel Server Error. Perhaps the in-memory configuration Jenkins is different from the disk configuration. Please try to reload the configuration
    from /Users/loa/workspace/github/jenkins_api_client/lib/jenkins_api_client/client.rb:721:in `handle_exception'
    from /Users/loa/workspace/github/jenkins_api_client/lib/jenkins_api_client/client.rb:351:in `api_post_request'
    from /Users/loa/workspace/github/jenkins_api_client/lib/jenkins_api_client/node.rb:175:in `create_dump_slave'
    from (irb):2
irb(main):009:0>

:mode => "normal"
:mode => "normal",
:private_key_file => "",
:credentialsId => ""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have this as credentials_id to be consistent with the rest of the variable naming in this method?

@loa
Copy link
Contributor Author

loa commented Feb 13, 2014

Ofc, totally missed this since we modified this in a rush to get it working with a PoC. How stupid of me to not see this pattern.

Anything else?

I will make the necessary changes tomorrow

@arangamani
Copy link
Owner

Nope, that's the only thing I can see. I'll go ahead and merge it once that is done. Thanks!

@loa
Copy link
Contributor Author

loa commented Feb 17, 2014

Fixed!

Hoping for a new gem release soon!

@@ -167,6 +170,7 @@ def create_dump_slave(params)
"port" => params[:slave_port],
"username" => params[:slave_user],
"privatekey" => params[:private_key_file],
"credentials_id" => params[:credentials_id]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean to change all occurrences of credentialsId to credentials_id. I believe this should be

"credentialsId" => params[:credentials_id]

or else jenkins wouldn't be able to recognize it. What I meant is that Jenkins uses the Java notation for attribute names and we wanted to keep it in Ruby style and then passing it correctly when passing it to Jenkins remote API. Is that clear?

Also if you could test it once, I would really appreciate it.

@loa
Copy link
Contributor Author

loa commented Feb 18, 2014

Done and tested.

Tested with irb and works perfectly!

@arangamani
Copy link
Owner

Awesome.
On a related note, if you do a lot of ruby development, try out pry instead of irb and you will love it.

arangamani added a commit that referenced this pull request Feb 18, 2014
@arangamani arangamani merged commit b0b5622 into arangamani:master Feb 18, 2014
@arangamani
Copy link
Owner

Version 1.0.0.beta.4 is now pushed to rubygems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants