Merged in ITPLT-4718-query-mpac-for-jsm-appSoftwareId (pull request #237)

ITPLT-4718: Resolve JSM Marketplace app-software IDs at runtime

Approved-by: Kevin Liou
This commit is contained in:
Lee Goolsbee
2026-08-07 20:14:13 +00:00
7 changed files with 98 additions and 16 deletions

View File

@@ -36,7 +36,10 @@ atl_product_family_to_mpac_parent_software_id_map:
stash: "bitbucket"
atl_mpac_base_url: "https://marketplace.atlassian.com"
atl_mpac_api_base_url: "{{ atl_mpac_base_url }}/rest/3"
atl_mpac_jsm_app_software_id: "1bbd1b4a-95cd-4762-b7ae-3e3e99eee7d8"
atl_mpac_jsm_app_key: "com.atlassian.servicedesk.application"
atl_mpac_jsm_hosting_preference:
- datacenter
- server
atl_mpac_product_latest_version_url: "{{ atl_mpac_api_base_url }}/parent-software/{{ atl_product_family_to_mpac_parent_software_id_map[atl_product_family] }}/versions?state=ACTIVE&limit=1"
atl_install_jsd_as_obr: false

View File

@@ -5,7 +5,8 @@
atl_product_family: "jira"
atl_product_edition: "jira-software"
atl_product_user: "jira"
# Version 8.14.0 is chosen deliberately as it is a version where jira and jira-software returns different buildNumber from MPAC
# Version 8.14.0 has different jira and jira-software build numbers from MPAC.
# It also has no Data Center-hosted JSM record, exercising the Server fallback.
# See DCD-1216 for context
atl_product_version: "8.14.0"
atl_install_jsd_as_obr: true

View File

@@ -31,7 +31,7 @@ def test_is_unpacked(host):
assert installer.user == 'jira'
assert installer.mode == 0o0755
def test_obr_is_downloaded(host):
def test_obr_is_downloaded_via_server_fallback(host):
installer = host.file('/media/atl/downloads/jira-servicedesk-application-4.14.0.obr')
assert installer.exists
assert installer.user == 'root'

View File

@@ -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']['server']['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')

View File

@@ -0,0 +1,26 @@
---
- name: Marketplace JSM - Resolve app software IDs by hosting preference
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 }}"
register: atl_jsm_app_software_lookup
- name: Marketplace JSM - Set non-archived app software IDs
ansible.builtin.set_fact:
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 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(', ') }}.

View File

@@ -19,23 +19,54 @@
ansible.builtin.debug:
msg="buildNumber={{ atl_product_version_info.json.buildNumber }}"
- name: Marketplace OBR - Get the JSD build version info
- name: Marketplace OBR - Resolve JSM app software IDs
ansible.builtin.include_tasks: jira-servicedesk_app_software_ids.yml
- name: Marketplace OBR - Get JSD build version info for resolved app software IDs
ansible.builtin.uri:
url: "{{ atl_mpac_api_base_url }}/app-software/{{ atl_mpac_jsm_app_software_id }}/versions?parentSoftwareId=jira&parentSoftwareVersionId={{ atl_product_version_info.json.buildNumber }}&state=ACTIVE&limit=1"
return_content: yes
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 }}"
register: atl_jsd_build_info
- name: Marketplace OBR - Set compatible JSD build versions
ansible.builtin.set_fact:
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 - 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_builds_with_artifacts | length > 0
fail_msg: >-
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_builds_with_artifacts | first }}"
- name: Marketplace OBR - Show the returned obr artifact ID
ansible.builtin.debug:
msg="obr_artifact_id={{ atl_jsd_build_info.json.versions[0].frameworkDetails.attributes.artifactId }}"
msg="obr_artifact_id={{ atl_jsd_selected_build.frameworkDetails.attributes.artifactId }}"
- name: Marketplace OBR - Set atl_obr_download_url
ansible.builtin.set_fact:
atl_obr_download_url: "{{ atl_mpac_base_url }}/artifacts/{{ atl_jsd_build_info.json.versions[0].frameworkDetails.attributes.artifactId }}/download"
atl_obr_download_url: "{{ atl_mpac_base_url }}/artifacts/{{ atl_jsd_selected_build.frameworkDetails.attributes.artifactId }}/download"
- name: Marketplace OBR - Set atl_jsd_build
ansible.builtin.set_fact:
atl_jsd_build: "{{ atl_jsd_build_info.json.versions[0].versionNumber }}"
atl_jsd_build: "{{ atl_jsd_selected_build.versionNumber }}"
- name: Marketplace OBR - Show the obr filename
ansible.builtin.debug:

View File

@@ -1,9 +1,32 @@
---
- name: Fetch the latest version from URL
- name: Resolve JSM app software IDs
ansible.builtin.include_tasks: jira-servicedesk_app_software_ids.yml
- name: Fetch latest JSM versions for resolved app software IDs
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 }}"
register: atl_jsm_latest_version_info
- name: Set compatible latest JSM versions
ansible.builtin.set_fact:
atl_product_version_json: "{{ lookup('url', '{{ atl_mpac_api_base_url }}/app-software/{{ atl_mpac_jsm_app_software_id }}/versions?parentSoftwareId=jira&state=ACTIVE&limit=1') }}"
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:
that:
- atl_jsm_latest_versions | length > 0
fail_msg: >-
Marketplace returned no active JSM version for app key {{ atl_mpac_jsm_app_key }}
using app software IDs {{ atl_jsm_app_software_ids | join(', ') }}.
- name: Set the local var to retrieved version
ansible.builtin.set_fact:
atl_latest_version: "{{ atl_product_version_json.versions[0].versionNumber }}"
atl_latest_version: "{{ (atl_jsm_latest_versions | first).versionNumber }}"