mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2026-07-30 09:40:48 -05:00
ITPLT-4718 Harden JSM Marketplace lookup
This commit is contained in:
@@ -12,11 +12,9 @@ def get_latest():
|
||||
req.add_header('User-Agent', 'ansible-httpget')
|
||||
data = urllib.request.urlopen(req)
|
||||
meta = json.loads(data.read().decode("UTF-8"))
|
||||
servicedesk = meta['name']
|
||||
jira = meta['compatibilities'][0]['hosting']['dataCenter']['max']['version']
|
||||
return (servicedesk, jira)
|
||||
return meta['name']
|
||||
|
||||
(sd, jira) = get_latest()
|
||||
sd = get_latest()
|
||||
|
||||
def test_version_is_correct(host):
|
||||
verfile = host.file('/media/atl/jira/shared/jira-servicedesk.version')
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
ansible.builtin.uri:
|
||||
url: "{{ atl_mpac_api_base_url }}/app-software/app-key/{{ atl_mpac_jsm_app_key }}?hosting={{ item }}"
|
||||
return_content: true
|
||||
status_code:
|
||||
- 200
|
||||
- 404
|
||||
loop: "{{ atl_mpac_jsm_hosting_preference }}"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
@@ -11,13 +14,13 @@
|
||||
|
||||
- name: Marketplace JSM - Set non-archived app software IDs
|
||||
ansible.builtin.set_fact:
|
||||
atl_jsm_app_software_ids: "{{ atl_jsm_app_software_lookup.results | map(attribute='json') | flatten | rejectattr('archived') | map(attribute='appSoftwareId') | list }}"
|
||||
atl_jsm_app_software_ids: "{{ atl_jsm_app_software_lookup.results | selectattr('status', 'equalto', 200) | map(attribute='json') | flatten | selectattr('appSoftwareId', 'defined') | selectattr('appSoftwareId') | selectattr('archived', 'defined') | selectattr('archived', 'equalto', false) | map(attribute='appSoftwareId') | unique | list }}"
|
||||
|
||||
- name: Marketplace JSM - Ensure at least one app software ID was resolved
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atl_jsm_app_software_ids | length > 0
|
||||
fail_msg: >-
|
||||
Marketplace did not return a non-archived app software ID for
|
||||
{{ atl_mpac_jsm_app_key }} using hosting preferences
|
||||
Marketplace did not return an app software record with a non-empty ID and
|
||||
archived set to false for {{ atl_mpac_jsm_app_key }} using hosting preferences
|
||||
{{ atl_mpac_jsm_hosting_preference | join(', ') }}.
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
ansible.builtin.uri:
|
||||
url: "{{ atl_mpac_api_base_url }}/app-software/{{ item }}/versions?parentSoftwareId=jira&parentSoftwareVersionId={{ atl_product_version_info.json.buildNumber }}&state=ACTIVE&limit=1"
|
||||
return_content: true
|
||||
status_code:
|
||||
- 200
|
||||
- 404
|
||||
loop: "{{ atl_jsm_app_software_ids }}"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
@@ -33,21 +36,25 @@
|
||||
|
||||
- name: Marketplace OBR - Set compatible JSD build versions
|
||||
ansible.builtin.set_fact:
|
||||
atl_jsd_build_versions: "{{ atl_jsd_build_info.results | map(attribute='json') | map(attribute='versions') | flatten | list }}"
|
||||
atl_jsd_build_versions: "{{ atl_jsd_build_info.results | selectattr('status', 'equalto', 200) | map(attribute='json') | selectattr('versions', 'defined') | map(attribute='versions') | flatten | list }}"
|
||||
|
||||
- name: Marketplace OBR - Ensure a compatible JSD build was returned
|
||||
- name: Marketplace OBR - Set compatible JSD builds with artifacts
|
||||
ansible.builtin.set_fact:
|
||||
atl_jsd_builds_with_artifacts: "{{ atl_jsd_build_versions | selectattr('frameworkDetails', 'defined') | selectattr('frameworkDetails.attributes', 'defined') | selectattr('frameworkDetails.attributes.artifactId', 'defined') | selectattr('frameworkDetails.attributes.artifactId') | list }}"
|
||||
|
||||
- name: Marketplace OBR - Ensure a compatible JSD build with an artifact was returned
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atl_jsd_build_versions | length > 0
|
||||
- atl_jsd_builds_with_artifacts | length > 0
|
||||
fail_msg: >-
|
||||
Marketplace returned no compatible JSM version for Jira {{ atl_product_version }}
|
||||
(build {{ atl_product_version_info.json.buildNumber }}) using app key
|
||||
{{ atl_mpac_jsm_app_key }} and app software IDs
|
||||
Marketplace returned no compatible JSM build with an OBR artifact for Jira
|
||||
{{ atl_product_version }} (build {{ atl_product_version_info.json.buildNumber }})
|
||||
using app key {{ atl_mpac_jsm_app_key }} and app software IDs
|
||||
{{ atl_jsm_app_software_ids | join(', ') }}.
|
||||
|
||||
- name: Marketplace OBR - Set selected JSD build version
|
||||
ansible.builtin.set_fact:
|
||||
atl_jsd_selected_build: "{{ atl_jsd_build_versions | first }}"
|
||||
atl_jsd_selected_build: "{{ atl_jsd_builds_with_artifacts | first }}"
|
||||
|
||||
- name: Marketplace OBR - Show the returned obr artifact ID
|
||||
ansible.builtin.debug:
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
ansible.builtin.uri:
|
||||
url: "{{ atl_mpac_api_base_url }}/app-software/{{ item }}/versions?parentSoftwareId=jira&state=ACTIVE&limit=1"
|
||||
return_content: true
|
||||
status_code:
|
||||
- 200
|
||||
- 404
|
||||
loop: "{{ atl_jsm_app_software_ids }}"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
@@ -14,7 +17,7 @@
|
||||
|
||||
- name: Set compatible latest JSM versions
|
||||
ansible.builtin.set_fact:
|
||||
atl_jsm_latest_versions: "{{ atl_jsm_latest_version_info.results | map(attribute='json') | map(attribute='versions') | flatten | list }}"
|
||||
atl_jsm_latest_versions: "{{ atl_jsm_latest_version_info.results | selectattr('status', 'equalto', 200) | map(attribute='json') | selectattr('versions', 'defined') | map(attribute='versions') | flatten | list }}"
|
||||
|
||||
- name: Ensure Marketplace returned a latest JSM version
|
||||
ansible.builtin.assert:
|
||||
|
||||
Reference in New Issue
Block a user