启动时访问jenkins JAR

时间:2016-07-31 18:32:00

标签: linux jenkins chef

我正在Chef中构建一本食谱,以便在Jenkins中创建一个自动化服务。我在CentOS上安装最新的Jenkins LTS,但我一直被拒绝访问jar文件。有没有人有解决方案来覆盖这个?

这是我的输出:

     * remote_file[/var/lib/jenkins/plugins/jenkins-cli.jar] action create[2016-07-31T16:35:43+00:00] ERROR: Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, retry 1/5
   [2016-07-31T16:35:48+00:00] ERROR: Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, retry 2/5
   [2016-07-31T16:35:53+00:00] ERROR: Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, retry 3/5
   [2016-07-31T16:35:58+00:00] ERROR: Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, retry 4/5
   [2016-07-31T16:36:03+00:00] ERROR: Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, retry 5/5
   [2016-07-31T16:36:08+00:00] WARN: remote_file[/var/lib/jenkins/plugins/jenkins-cli.jar] cannot be downloaded from http://localhost:8080/jnlpJars/jenkins-cli.jar: Connection refused - Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, giving up


       ================================================================================
       Error executing action `create` on resource 'remote_file[/var/lib/jenkins/plugins/jenkins-cli.jar]'
       ================================================================================

       Errno::ECONNREFUSED
       -------------------
       Connection refused - Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, giving up

       Cookbook Trace:
       ---------------
       /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/fanatics_pipeline/recipes/jenkins_plugins.rb

        44:     remote_file "#{node['plugins_dir']}/jenkins-cli.jar" do
        45:         source node['cli_jar']
        46:         action :create
        47:         mode '0755'
        48:         notifies :restart, "service[#{node['repo']['name']}]", :delayed
        49:     end
        50: end

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/fanatics_pipeline/recipes/jenkins_plugins.rb:44:in `block in from_file'

       remote_file("/var/lib/jenkins/plugins/jenkins-cli.jar") do
         provider Chef::Provider::RemoteFile
         action [:create]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         source ["http://localhost:8080/jnlpJars/jenkins-cli.jar"]
         use_etag true
         use_last_modified true
         declared_type :remote_file
         cookbook_name "fanatics_pipeline"
         recipe_name "jenkins_plugins"
         mode "0755"
         atomic_update true
         path "/var/lib/jenkins/plugins/jenkins-cli.jar"
       end

       Platform:
       ---------
       x86_64-linux

   Recipe: fanatics_pipeline::jenkins_install
     * service[jenkins] action restart
       - restart service service[jenkins]
     * service[jenkins] action reload
       - reload service service[jenkins]

   Running handlers:
   [2016-07-31T16:36:15+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2016-07-31T16:36:15+00:00] ERROR: Exception handlers complete
   Chef Client failed. 24 resources updated in 04 minutes 10 seconds
   [2016-07-31T16:36:15+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2016-07-31T16:36:15+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2016-07-31T16:36:15+00:00] ERROR: remote_file[/var/lib/jenkins/plugins/jenkins-cli.jar] (fanatics_pipeline::jenkins_plugins line 44) had an error: Errno::ECONNREFUSED: Connection refused - Connection refused connecting to http://localhost:8080/jnlpJars/jenkins-cli.jar, giving up
   [2016-07-31T16:36:17+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

2 个答案:

答案 0 :(得分:0)

假设Jenkins需要更长时间才能启动,您可以增加Chef承担检索文件的retries数量:

remote_file "#{node['plugins_dir']}/jenkins-cli.jar" do
  source node['cli_jar']
  retries 60
  action :create
  mode '0755'
  notifies :restart, "service[#{node['repo']['name']}]", :delayed
end

这将尝试60次。

答案 1 :(得分:-1)

在尝试下载JAR之前,您需要确保启动Jenkins。还要确保没有防火墙或其他阻塞端口的东西。