Configuring Your CI/CD Pipeline
Set up microservice discovery in your CI/CD pipeline using a manifest file and a Python script.
Early Adopter Release
This feature is currently in early adopter release and may not be available to all customers.
Overview
Implementing microservice discovery within your Continuous Integration and Continuous Deployment (CI/CD) pipeline allows your system to automatically detect and integrate any changes made to your microservices. This automated process ensures that your microservices are consistently updated and accurately represented within your system.
Establishing a CI/CD workflow within your repository is a key step in automating the discovery and update process of your microservices. This workflow reduces manual intervention and minimizes potential errors, resulting in a more reliable and efficient system.
Although it's possible to register microservices through API requests in an environment without a CI/CD pipeline, we recommend following the CI/CD approach. This recommendation stems from the need to maintain up-to-date data. In this setup, your manifest file serves as the source of truth, and any changes to it automatically reflect in your microservices. This approach simplifies the microservice discovery process and enhances the accuracy and consistency of your microservice fact sheets, improving overall system reliability and performance.
This guide details how to set up microservice discovery in the CI/CD pipeline using a manifest file and a Python script.
Prerequisites
Prepare the following:
- YAML manifest file
- Relevant Python script
To learn how to create a YAML file and a Python script, see Microservice Discovery in Your CI/CD Pipeline.
To view the manifest file and schema, refer to Manifest File and Schema.
Configuration
This section details how to set up microservice discovery in the CI/CD pipeline for specific Git providers.
The pipeline in this guide includes the following steps:
- Checking out your code.
- Setting up Python.
- Installing the necessary Python dependencies.
- Invoking the SAP LeanIX service discovery Python helper.
Azure CI/CD Discovery
The Azure pipeline outlined here automatically updates your microservices on each push to the main
branch, ensuring your microservice fact sheets remain current.
To set up this pipeline, create a new azure-pipelines.yml
file in your repository root. The following YAML script outlines the pipeline:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.12'
addToPath: true
- script: |
python -m pip install --upgrade pip
pip install requests pyyaml
displayName: 'Install dependencies'
- script: python leanix_service_discovery.py
displayName: 'Invoke Manifest Parser'
Bitbucket CI/CD Discovery
The Bitbucket pipeline outlined here automatically updates your microservices on each push to the main
branch, ensuring your microservice fact sheets remain current.
To set up this pipeline, create a new bitbucket-pipelines.yml
file in your repository root. The following YAML script outlines the pipeline:
pipelines:
default:
- step:
name: Update Microservice
image: python:3.12
script:
- pip install --upgrade pip
- pip install requests pyyaml
- python leanix_service_discovery.py
GitHub CI/CD Discovery
The GitHub pipeline outlined here automatically updates your microservices on each push or pull request to the main
branch, ensuring your microservice fact sheets remain current.
To set up this workflow, create a new GitHub workflow in your repository under .github/workflows
. For instructions, refer to the GitHub documentation.
The following YAML script outlines the workflow:
name: Microservice Workflow
on:
pull_request:
types:
- closed
branches: [main]
env:
LEANIX_API_TOKEN: ${{ secrets.LEANIX_API_TOKEN }}
LEANIX_SUBDOMAIN: ${{ vars.LEANIX_SUBDOMAIN }}
jobs:
update_microservice:
runs-on: ubuntu-latest
env:
REPOSITORY_URL: ${{ github.repositoryUrl }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install requests pyyaml
- name: Invoke Manifest Parser
run: python leanix_service_discovery.py
GitLab CI/CD Discovery
The GitLab CI/CD pipeline outlined here automatically updates your microservices on each push or merge request to the main
branch, ensuring your microservice fact sheets remain current.
To set up this pipeline, create or update your .gitlab-ci.yml
file in your repository root. The following YAML script outlines the pipeline:
stages:
- update_microservice
update_microservice:
image: python:3.12
script:
- pip install --upgrade pip
- pip install requests pyyaml
- python leanix_service_discovery.py
only:
- main
Updated 5 days ago