Taskcluster URLs
Taskcluster-urls is a Python library that provides a standardized way to generate URLs for various Taskcluster resources, such as tasks, artifacts, and releases. It helps integrate with the Taskcluster ecosystem by providing a consistent API for URL construction. As of version 13.0.2, it's actively maintained, with releases often tied to a monorepo that includes JavaScript and Go implementations, so not all version bumps directly imply Python-specific changes.
Warnings
- breaking In v12.0.0, the `servicesManifest` method was renamed to `apiManifest`. Calls to the old method will fail.
- breaking In v11.0.0, the default `testRootUrl` used within the library changed from `https://tc-tests.localhost` to `https://tc-tests.example.com`. This primarily affects internal testing or any consumer relying on this specific default for test environments.
- gotcha The `TaskclusterUrls` constructor requires a valid `rootUrl`. Passing an empty or `None` value will raise a `ValueError`.
Install
-
pip install taskcluster-urls
Imports
- TaskclusterUrls
from taskcluster_urls import TaskclusterUrls
Quickstart
import os
from taskcluster_urls import TaskclusterUrls
# Replace with your Taskcluster root URL or set as an environment variable
root_url = os.environ.get('TASKCLUSTER_ROOT_URL', 'https://taskcluster.net')
try:
urls = TaskclusterUrls(root_url)
# Example 1: Get a URL for a specific task in the queue
task_id = 'my-task-id'
run_id = 'my-run-id'
queue_task_url = urls.queue.task(task_id, run_id)
print(f"Queue Task URL: {queue_task_url}")
# Example 2: Get a URL for a specific artifact of a task
artifact_path = 'public/logs/live_logs.txt'
artifact_url = urls.queue.artifact(task_id, run_id, artifact_path)
print(f"Artifact URL: {artifact_url}")
# Example 3: Get a URL related to a release
release_id = 'my-release-id'
release_task_url = urls.release(release_id).task(task_id, run_id)
print(f"Release Task URL: {release_task_url}")
except ValueError as e:
print(f"Error initializing TaskclusterUrls: {e}")