Lifecycle Management

Automated SDLC Pipeline with Tray APIs

Setting Up an Automated SDLC Pipeline with Tray APIs

Prerequisites

Before setting up the automated SDLC pipeline using Tray’s Projects and Solutions APIs, ensure the following prerequisites are met:

  • Documentation: Familiarize yourself with Tray’s public developer documentation site at developer.tray.io, which provides a comprehensive reference for the Projects and Solutions API endpoints, including intended use cases and available functions.
  • Source and destination workspaces: You need an existing source and destination workspace for project deployment. Projects cannot currently be created via API, so they must be manually set up.
  • Authentication: You must have valid authentication tokens (user or master tokens) to interact with Tray APIs. Tokens are environment-specific and region-sensitive.
  • Auth matching: Ensure that all required authentications exist in both source and destination workspaces. Auth IDs must be mapped accordingly.
  • Versioning: Declare a version of the project before attempting to deploy it. Versions can be created via the UI or API.

Setup process

  1. Retrieve source project version information
  • Purpose: Ensures that you are deploying the correct version of the project.
  • Call the GET /core/v1/projects/{projectId}/versions endpoint to fetch available versions.
  • Ensure the latest version is retrieved for deployment to prevent outdated configurations.
  1. Export the source project version
  • Purpose: Exports the project version in a format suitable for migration.
  • Use GET /core/v1/projects/{projectId}/versions/{versionNumber}/export to fetch the project version JSON.
  • Convert the stringified JSON into a structured object for further processing to avoid parsing issues later.
  1. Check import requirements (optional for initial deployments or authentication changes)
  • Purpose: Determines whether additional configuration is needed before importing the project.
  • Call POST /core/v1/projects/{projectId}/imports/requirements with the exported project JSON.
  • Identify any required authentication mappings or configuration mappings that need to be resolved.
  1. Preview the import
  • Purpose: Simulates the import process to detect potential issues before making changes.
  • Call POST /core/v1/projects/{projectId}/imports/previews to analyze potential changes before deployment.
  • Ensure there are no conflicts or missing dependencies, preventing failed deployments.
  1. Import the project version
  • Purpose: Overwrites the project in the destination workspace with the new version.
  • Call POST /core/v1/projects/{projectId}/imports with the required mappings (that can be hardcoded in your pipeline) and project JSON.
  • Validate the response for any errors to confirm a successful import.
  1. Create a version in the destination workspace
  • Purpose: Establishes a restore point for rollback capabilities in case of future issues and ensures version numbering consistency across environments.
  • Call POST /core/v1/projects/{projectId}/versions/{versionNumber} to create a version
  • It is recommended to match the source version ID in the destination workspace to maintain consistency.

Additional steps for embedded solutions

  1. Ensure solution exists
  2. Retrieve solution ID: After import, use the response payload to extract the new solution ID.
  3. Publish the solution:
  • Call POST /core/v1/solutions/{solutionId}/releases/previews to to analyze potential changes and solution instances impact before publishing.
  • Call POST /core/v1/solutions/{solutionId}/releases to publish the solution.

Pipeline setup using Tray

You can build your automated pipeline using Tray workflows. This video provides a walkthrough of an example implementation. Here are some best practices for implementing pipelines in Tray:

  • Use config: Store workspace IDs, auth mappings, and base URLs in config.
  • Implement error handling: Monitor API responses and handle errors gracefully to allow retrying failed steps.
  • Leverage logs: Utilize logs for debugging.
  • Automate with webhooks: Consider triggering deployments automatically based on repository changes or CI/CD pipelines.
  • Ensure region compatibility: Use the correct base URLs based on the region to prevent cross-region deployment issues.

Was this page helpful?