1
0
Fork 0
This repository has been archived on 2023-11-22. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ansible-jenkins-php-v1/roles/jenkins-php-v1/tasks/include_jobinstall.yml

35 lines
1.3 KiB
YAML
Raw Normal View History

2020-01-17 23:35:15 +01:00
---
# When the job doesn't exist, we provide an empty XML, and then work
# directly on the jenkins_home/jobs/JOB/config.xml file
- name: Create a empty job
shell: "echo '<project />' | {{ jenkins_cli_command }} create-job {{ job.key | quote }}"
when: job.key not in current_jobs_list.stdout_lines
- name: Upload job config template
template:
src: "{{ item }}"
# if job exists, we write directly to jobs/JOBNAME/config.xml, else we write to the tmp file.
dest: "{{ jenkins_home + '/jobs/' + job.key + '/config.xml' }}"
mode: 0600
owner: jenkins
group: jenkins
backup: yes
force: yes
with_first_found:
- "jobs/config.xml.{{ ansible_fqdn }}.{{ job.key }}.j2"
- "jobs/config.xml.{{ job.key }}.j2"
- "jobs/config.xml.{{ ansible_fqdn }}.j2"
- "jobs/config.xml.j2"
register: jobconfig
- name: Reload the job
shell: "{{ jenkins_cli_command }} reload-job {{ job.key | quote }}"
when: jobconfig.changed
- name : Add info for the manual todo list at the end
set_fact:
jenkins_post_install: |-
{{ jenkins_post_install|default([]) + [ "- in project '" + job.key + "', add webhook '" + nginx_vhost_ssl|ternary('https', 'http') + '://' + giteaUsername + ':' + giteaPassword + '@' + nginx_vhost_main_hostname + '/git/notifyCommit?url=' + job.value.repository_url ] }}
when: job.value.repository_url is defined