Skip to content

Commit

Permalink
update plugin manager command (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhan9san committed Oct 26, 2024
1 parent a336682 commit 8610490
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
13 changes: 12 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jenkins_plugin_manager_url: "{{ jenkins_plugin_manager_url_prefix }}/{{ jenkins_
jenkins_tool_dir: /opt/jenkins_tool
jenkins_plugin_manager_path: "{{ jenkins_tool_dir }}/jenkins-plugin-manager.jar"

jenkins_plugin_file: plugins.txt
jenkins_plugin_file: ""
jenkins_plugin_file_path: "{{ jenkins_tool_dir }}/plugins.txt"

# For JCasc
Expand Down Expand Up @@ -70,3 +70,14 @@ jenkins_download_proxy:
jenkins_plugin_manager_proxy_port: "{{ '-Dhttp.proxyPort=' ~ jenkins_proxy_port ~ ' -Dhttps.proxyPort=' ~ jenkins_proxy_port if jenkins_proxy_port else '' }}"
jenkins_plugin_manager_proxy_host: "{{ '-Dhttp.proxyHost=' ~ jenkins_proxy_host ~ ' -Dhttps.proxyHost=' ~ jenkins_proxy_host if jenkins_proxy_host else '' }}"
jenkins_plugin_manager_non_proxy_hosts: "{{ '-Dhttp.nonProxyHosts=' ~ jenkins_non_proxy_hosts if jenkins_non_proxy_hosts else '' }}"

# no double quotes needed if `>` is used
jenkins_plugin_installation_cmd: >
{{ java_bin }}
{{ jenkins_plugin_manager_proxy_port }}
{{ jenkins_plugin_manager_proxy_host }}
{{ jenkins_plugin_manager_non_proxy_hosts }}
-jar {{ jenkins_plugin_manager_path }}
-w /usr/share/java/jenkins.war
-f {{ jenkins_plugin_file_path }}
-d {{ jenkins_home }}/plugins
14 changes: 8 additions & 6 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
- name: Converge
hosts: all
vars:
jdk_version: 21.0.2
java_home: /opt/jdk-21.0.2
jenkins_jcasc_template: jenkins.yaml.j2
jenkins_systemd_unit_envs:
java_home: "{{ java_home }}"
tasks:
- name: "Include zhan9san.java"
ansible.builtin.include_role:
name: "zhan9san.java"
vars:
jdk_version: 21.0.2
- name: "Include zhan9san.jenkins"
ansible.builtin.include_role:
name: "zhan9san.jenkins"
vars:
java_home: /opt/jdk-21.0.2
jenkins_plugin_file: plugins.txt
jenkins_jcasc_template: jenkins.yaml.j2
jenkins_systemd_unit_envs:
java_home: "{{ java_home }}"
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- name: Set up Plugin
ansible.builtin.include_tasks:
file: "setup-plugin.yml"
when: jenkins_plugin_file

- name: Set up JCasc
ansible.builtin.include_tasks:
Expand Down
2 changes: 1 addition & 1 deletion tasks/setup-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

- name: Install plugins
ansible.builtin.command:
cmd: "{{ java_bin }} -jar {{ jenkins_plugin_manager_path }} -w /usr/share/java/jenkins.war -f {{ jenkins_plugin_file_path }} -d {{ jenkins_home }}/plugins {{ jenkins_plugin_manager_proxy_port }} {{ jenkins_plugin_manager_proxy_host }} {{ jenkins_plugin_manager_non_proxy_hosts }}" # yamllint disable-line rule:line-length
cmd: "{{ jenkins_plugin_installation_cmd }}"
when: copy_result.changed # noqa: no-handler
register: command_result
changed_when: true
Expand Down

0 comments on commit 8610490

Please sign in to comment.