Michal Zegan | 3a7e073 | 2018-12-19 11:51:26 +0100 | [diff] [blame] | 1 | --- |
| 2 | - name: "check if the configuration script is uploaded" |
| 3 | uri: |
| 4 | url: "{{ nexus_url }}/service/rest/v1/script/configure" |
| 5 | method: GET |
| 6 | force_basic_auth: yes |
| 7 | user: admin |
| 8 | password: admin123 |
| 9 | status_code: [200, 404] |
| 10 | register: script |
| 11 | - block: |
| 12 | - name: "upload the configuration script" |
| 13 | uri: |
| 14 | url: "{{ nexus_url }}/service/rest/v1/script" |
| 15 | method: POST |
| 16 | force_basic_auth: yes |
| 17 | user: admin |
| 18 | password: admin123 |
| 19 | body_format: json |
| 20 | body: |
| 21 | name: configure |
| 22 | type: groovy |
| 23 | content: "{{ lookup('file', 'files/configure.groovy') }}" |
| 24 | status_code: [204] |
| 25 | - name: "execute configuration script" |
| 26 | uri: |
| 27 | url: "{{ nexus_url }}/service/rest/v1/script/configure/run" |
| 28 | method: POST |
| 29 | force_basic_auth: yes |
| 30 | user: admin |
| 31 | password: admin123 |
| 32 | body_format: raw |
| 33 | headers: { "Content-Type": "text/plain" } |
| 34 | when: script.status == 404 |