For audit reason we need to download all the components of our Atlassian Compass.
Is it possibile to extract in Excel all the Components with last updates date?
Hello @Nicolò Spito
I hope this message finds you well. My name is Kelvin, and I’m with the Compass Support Team.
At this time, Compass does not offer a native feature to export components to a CSV file. However, you can use the Python script below to generate a CSV file with your Compass components.
Please note that this script was not developed by Atlassian and is therefore not officially supported. We recommend reviewing it carefully before running it.
import base64 import json import requests import csv # Define your variables here cloudId = "Your-cloudID" api_token = "Your-API-TOKEN" email = "Email" # Adjust the query to use the cloudId variable query = f""" query MyQuery {{ compass {{ searchComponents(cloudId: "{cloudId}", query: {{first: 10}}) {{ ... on CompassSearchComponentConnection {{ edges {{ cursor node {{ component {{ name typeId description labels {{ name }} links {{ url }} ownerId applicableScorecards {{ componentTiers {{ value }} }} }} }} }} totalCount }} }} }} }} """ url = "https://api.atlassian.com/graphql" auth_header = f"{email}:{api_token}" encoded_auth_header = base64.b64encode(auth_header.encode('utf-8')).decode('utf-8') headers = { "Content-Type": "application/json", "Accept": "application/json", "Authorization": f"Basic {encoded_auth_header}", "X-ExperimentalApi": "compass-beta" } request_data = { "query": query, } response = requests.post(url, headers=headers, json=request_data) response_data = json.loads(response.text) # Extract the component data components = response_data.get('data', {}).get('compass', {}).get('searchComponents', {}).get('edges', []) # Define the CSV filename csv_filename = 'components.csv' # Write the data to a CSV file with open(csv_filename, mode='w', newline='') as csv_file: fieldnames = ['name', 'type', 'description', 'labels', 'links', 'owner team', 'applicable scorecards'] writer = csv.DictWriter(csv_file, fieldnames=fieldnames) writer.writeheader() for component in components: node = component.get('node', {}) component_data = node.get('component', {}) writer.writerow({ 'name': component_data.get('name', ''), 'type': component_data.get('typeId', ''), 'description': component_data.get('description', ''), 'labels': ', '.join([label.get('name', '') for label in component_data.get('labels', [])]), 'links': ', '.join([link.get('url', '') for link in component_data.get('links', [])]), 'owner team': component_data.get('ownerId', ''), 'applicable scorecards': ', '.join([str(tier.get('value', '')) for scorecard in component_data.get('applicableScorecards', []) for tier in scorecard.get('componentTiers', [])]) }) print(f"Data exported to '{csv_filename}'")
As far as I know, this is not possible (yet?). I guess you want some sort of CSV file that contains all your components with certain fields and then edit/open this file with Excel, right? With a similar (or same) structure like the CSV import from this documentation page ?
Edit: Haven’t seen the other answer before posting 😀
Edit2: We were missing this feature as well and hence, we have recently published an app Component Exporter to the marketplace which you can use to export your Compass component data to CSV, i.e. name, description, links, custom fields, etc. So everyone without scripting skills can export the data now as well Hope this helps a few people.
Hi Kevin Thanks for your snippet here it's very handy I have for the life of me not been able to get the value of a CustomField or a Field element Can you please update your query to provide a sample of this?Component > CustomFields yields CompassCustomField which have implmentations like CompassCustomTextField that have textValue but I cant work out how to access it. Do I need to cast??
Mainly for audit reason or to underlight the components that need update from the owners.
It looks like you're new here. Sign in or register to get started.