---
- include: jenkins_23232.yml

- include: security.yml
  tags: solita_jenkins_security

- include: plugins.yml

- name: copy job-dsl-config.xml to destination
  become: yes
  become_user: jenkins
  copy: src={{ role_path }}/files/job-dsl-config.xml dest=/var/lib/jenkins/job-dsl-config.xml

- name: Create the job-dsl job
  shell: java -jar {{ jenkins_jar_location }} -s http://{{ jenkins_hostname }}:{{ jenkins_http_port }}/ create-job job-dsl < '/var/lib/jenkins/job-dsl-config.xml'
  args:
    creates: /var/lib/jenkins/jobs/job-dsl/config.xml
  register: create_job_dsl_job

- name: Update the job-dsl job configuration
  become: yes
  become_user: jenkins
  copy:
    src: job-dsl-config.xml
    dest: /var/lib/jenkins/jobs/job-dsl/config.xml
  register: update_job_dsl_job

- name: Reload the job-dsl job
  command: java -jar {{ jenkins_jar_location }} -s http://{{ jenkins_hostname }}:{{ jenkins_http_port }}/ reload-job job-dsl
  when: update_job_dsl_job | changed

- include: jobs.yml
  tags: solita_jenkins_jobs

---
- include: jenkins_23232.yml

- include: security.yml
  tags: solita_jenkins_security

- include: plugins.yml

- name: copy job-dsl-config.xml to destination
  become: yes
  become_user: jenkins
  copy: src={{ role_path }}/files/job-dsl-config.xml dest=/var/lib/jenkins/job-dsl-config.xml

- name: Create the job-dsl job
  shell: java -jar {{ jenkins_jar_location }} -s '{{ solita_jenkins_url }}' create-job job-dsl < '/var/lib/jenkins/job-dsl-config.xml'
  args:
    creates: /var/lib/jenkins/jobs/job-dsl/config.xml
  register: create_job_dsl_job

- name: Update the job-dsl job configuration
  become: yes
  become_user: jenkins
  copy:
    src: job-dsl-config.xml
    dest: /var/lib/jenkins/jobs/job-dsl/config.xml
  register: update_job_dsl_job

- name: Reload the job-dsl job
  command: java -jar {{ jenkins_jar_location }} -s '{{ solita_jenkins_url }}' reload-job job-dsl
  when: update_job_dsl_job | changed

- include: jobs.yml
  tags: solita_jenkins_jobs

Use solita_jenkins_url when creating the job-dsl job
Use solita_jenkins_url when creating the job-dsl job
