Skip to content

Commit

Permalink
Abort when json file found in node config and show user-friendly message
Browse files Browse the repository at this point in the history
  • Loading branch information
cynipe committed Jul 12, 2014
1 parent 3cd012c commit fe2ed1e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
40 changes: 40 additions & 0 deletions features/config_nodes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,43 @@ Feature: Configuring Nodes
"""
node node1 created.
"""

Scenario: Configuring the node with Json
Given the plain Jenkins server
And a file named "Capfile" with:
"""
require 'jenkins-capistrano'
load 'config/deploy'
"""
And a file named "config/deploy.rb" with:
"""
set :jenkins_host, 'http://localhost:8080'
"""
And a file named "config/jenkins/nodes/node1.json" with:
"""
{
"description" : "Slave1",
"slave_fs" : "/home/jenkins",
"executors" : 5,
"exclusive" : true,
"labels" : "hello",
"slave_host" : "dev-slave01.local",
"slave_port" : 22,
"slave_user" : "jenkins",
"master_key" : "/var/lib/jenkins/.ssh/id_rsa",
"jvm_options" : "-Dfile.encoding=UTF-8",
"env_vars": {
"LANG" : "ja_JP.UTF-8",
"ENVIRONMENT" : "production",
}
}
"""
When I run `bundle exec cap jenkins:config_nodes`
Then the exit status should be 1
And the output should contain:
"""
Configuring the node using json is not supported anymore, use config.xml instead.
You could get the node's config.xml from a running Jenkins with following command:
$ curl -o config/jenkins/nodes/<node_name>.xml http://<jenkins-host>/computer/<node_name>/config.xml
"""
1 change: 1 addition & 0 deletions lib/jenkins-capistrano/configurator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'pathname'
require 'jenkins-capistrano/template'
require 'jenkins_api_client'

Expand Down
6 changes: 6 additions & 0 deletions lib/jenkins-capistrano/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def #{name}_configs
DESC
task :config_nodes do
logger.info "configuring jenkins nodes to #{jenkins_host}"
abort <<-MSG.gsub(/^ +/, '') unless Dir.glob(File.join(jenkins_node_config_dir, '*.json')).empty?
Configuring the node using json is not supported anymore, use config.xml instead.
You could get the node's config.xml from a running Jenkins with following command:
$ curl -o config/jenkins/nodes/<node_name>.xml http://<jenkins-host>/computer/<node_name>/config.xml
MSG
configurator.configure_nodes(node_configs)
end

Expand Down

0 comments on commit fe2ed1e

Please sign in to comment.