【问题标题】:Unable to install git and related plugins in Jenkins using Ansible无法使用 Ansible 在 Jenkins 中安装 git 和相关插件
【发布时间】:2015-07-14 10:29:27
【问题描述】:

我正在尝试使用 Ansible 安装以下 Jenkins 插件(在安装 Jenkins 时)

git,git-client,ssh,scm-api,shiningpanda 插件

执行包ssh, scm-api, shiningpanda plugins 安装后。git and git-client 不在已安装插件列表中。 以下是我使用的代码和代码链接:

- name: Get the jenkins-cli jarfile from the Jenkins server
  get_url:
    url: "http://{{host-name}}:8080/jnlpJars/jenkins-cli.jar"
    dest: "/opt/jenkins-cli.jar"
  register: jarfile_get
  until: "'OK' in jarfile_get.msg or 'file already exists' in jarfile_get.msg"
  retries: 5
  delay: 10

- name: Install Jenkins plugins
  command: >
    java -jar /opt/jenkins-cli.jar -s http://{{host-name}}:8080/ install-plugin {{ item }}
    creates=/var/lib/jenkins/plugins/{{ item }}.jpi
  with_items: jenkins_plugins
  notify: restart jenkins

- name: Force a change of owner for all plugins
  shell: chown -R konfilarity:konfilarity /var/lib/jenkins/plugins/*
  notify: restart jenkins

链接到引用的 ansible 脚本:Install-jenkins-plugin-ansible

【问题讨论】:

  • 你能发布 Ansible 执行的输出吗?是否显示任何错误?
  • 当我在 ip:192.168.33.14 的 vagrant 机器上运行时,它给出了以下输出: TASK: [build_server_jenkins |安装 Jenkins 插件] ************************ 跳过:[192.168.33.14] => (item=credentials) 跳过:[192.168.33.14] = > (item=ssh-credentials) 更改:[192.168.33.14] => (item=git-client) 更改:[192.168.33.14] => (item=git) 更改:[192.168.33.14] => (item= ssh) 跳过:[192.168.33.14] => (item=scm-api) 更改:[192.168.33.14] => (item=shiningpanda) 更改:[192.168.33.14] => (item=test-results-analyzer)

标签: git jenkins-plugins ansible


【解决方案1】:

您可能希望在 Jenkins 命令任务中添加 register: jenkins_outputfailed_when: 子句,并让 failed_when 检查 jenkins_output.stdoutjenkins_output.stderr 以判断成功/失败。我不知道 install-plugin,但许多 Jenkins-cli 命令在失败时不会返回非零退出代码,所以 Ansible 不知道它坏了。

【讨论】:

    【解决方案2】:

    以下代码有效:

     - name: Force a change of owner for all plugins
          shell: chown -R jenkins:jenkins /var/lib/jenkins/plugins/*
    

    唯一的原因是所有者和组不是詹金斯。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      相关资源
      最近更新 更多