【问题标题】:Accessing jenkins JAR upon startup在启动时访问 jenkins JAR
【发布时间】:2016-08-01 14:39:31
【问题描述】:

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

这是我的输出:

     * 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)

【问题讨论】:

    标签: linux jenkins chef-infra


    【解决方案1】:

    假设 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 次。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 我认为问题是防火墙问题,但 Jenkins 网站上的解决方案并没有太大帮助。出于某种原因,Chef 在构建和配置 Jenkins 时,不允许从正在运行的 Jenkins 服务器下载内置插件。
      • 不幸的是,Linux 有很多不同的防火墙控制工具,所以在不知道您使用的是哪一个的情况下,我无法更具体。
      猜你喜欢
      • 2023-03-26
      • 2019-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-27
      • 1970-01-01
      相关资源
      最近更新 更多