In this example you will create a blueprint for package
entity that ingests all third party dependencies in your requirements.txt file using a combination of REST API and Webhook. You will then relate this package
blueprint to a service
blueprint, allowing you to display all the packages used by a service. Also, you will add some script to transform your requirements file into a format required by the webhook (which is mostly JSON Array for the dependencies
property). Finally, you will configure your Gitlab to create/update your entities in Port every time a deployment is made to a specified branch such as main/dev.
Create the service blueprint in Port using this json file
Create the package blueprint in Port using this json file
Use the webhook configuration file to create your Port webhook.
Follow the example guide on how to create a Port webhook. You will then use the webhook URL to ingest data to Port via REST API.
Place this example .gitlab-ci.yml
file in your project's root folder
To interact with Port using Gitlab CI Pipeline, you will first need to define your Port credentials as variables for your pipeline. Then, pass the defined variables to your ci pipeline script. Ensure that the SERVICE_ID variable exists as an identifier in your port service
blueprint.
The list of the required variables to run this pipeline are:
SERVICE_ID
WEBHOOK_URL
PATH_TO_REQUIREMENTS_TXT_FILE
This project contains example python resources that can be replaced with the shell script if you're using Python programming.