- 'postbuildscript'
- 'jobConfigHistory'
- - port: 8080
+ - jenkins_port: 8080
- prefix: '/build'
- xmx: 8192
# Email support
---
placeholder: 'placeholder'
-port: 8080
+jenkins_port: 8080
# plugins:
# - 'ldap'
# - 'github'
# Safe-restart Jenkins
- name: restart jenkins
- command: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ port }} safe-restart
+ command: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ jenkins_port }} safe-restart
- name: restart nginx
service:
lineinfile:
dest: '{{ jenkins.apt.config_file }}'
regexp: ^HTTP_PORT=
- line: HTTP_PORT={{port}}
+ line: HTTP_PORT={{jenkins_port}}
backrefs: yes
register: config_changed
- name: "{{ startup_delay_s | default(10) }}s delay while starting Jenkins"
wait_for:
host: localhost
- port: '{{ port }}'
+ port: '{{ jenkins_port }}'
delay: '{{ startup_delay_s | default(10) }}'
when: jenkins_install.changed or config_changed.changed
- name: Get Jenkins CLI
get_url:
- url: http://localhost:{{ port }}/jnlpJars/jenkins-cli.jar
+ url: http://localhost:{{ jenkins_port }}/jnlpJars/jenkins-cli.jar
dest: '{{ jenkins.cli_dest }}'
mode: 0440
register: jenkins_local_cli
register: jenkins_updates
- name: Update-center Jenkins
- shell: "cat {{ jenkins.updates_dest }} | sed '1d;$d' | curl -X POST -H 'Accept: application/json' -d @- http://localhost:{{ port }}/updateCenter/byId/default/postBack"
+ shell: "cat {{ jenkins.updates_dest }} | sed '1d;$d' | curl -X POST -H 'Accept: application/json' -d @- http://localhost:{{ jenkins_port }}/updateCenter/byId/default/postBack"
when: jenkins_updates.changed
notify:
- 'restart jenkins'
---
- name: List plugins
- shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ port }} list-plugins | cut -f 1 -d ' '
+ shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ jenkins_port }} list-plugins | cut -f 1 -d ' '
when: plugins is defined
register: plugins_installed
- name: Install/update plugins
- shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ port }} install-plugin {{ item }}
+ shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ jenkins_port }} install-plugin {{ item }}
when: plugins_installed.changed and plugins_installed.stdout.find('{{ item }}') == -1
with_items: plugins
notify:
- 'restart jenkins'
- name: List plugins to be updated
- shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ port }} list-plugins | grep ')$' | cut -f 1 -d ' ' | sed ':a;N;$!ba;s/\n/ /g'
+ shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ jenkins_port }} list-plugins | grep ')$' | cut -f 1 -d ' ' | sed ':a;N;$!ba;s/\n/ /g'
register: plugins_updates
- name: Update plugins
- shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ port }} install-plugin {{ item }}
+ shell: java -jar {{ jenkins.cli_dest }} -s http://localhost:{{ jenkins_port }} install-plugin {{ item }}
with_items: plugins_updates.stdout.split()
when: plugins_updates.stdout != ''
ignore_errors: yes