Skip to main content

Codefresh Workflow Template

Our Codefresh workflow template allows you to create/update and query entities in Port directly from your Codefresh workflow templates.



CircleCI Illustration

💡 Codefresh integration usage​

Port's Codefresh workflow template provides a native way to integrate Port with your Codefresh CI workflows, for example:

  • Report the status of a running CI job;
  • Update the software catalog about a new build version for a microservice;
  • Get existing entities.

Installation​

To use Port's Codefresh workflow template you need to perform the following steps:

  1. Go to the workflow template repository in GitHub;
  2. Copy the file portWorkflowTemplate.yml to one of your codefresh git sources and commit it to your git source;
  3. Add the required service account, cluster role and role binding to your codefresh runtime namespace by applying the contents of the rbac.yml file by using the command: kubectl apply -f rbac.yml -n YOUR_NAMESPACE;
  4. Add the required secret containing your PORT_CLIENT_ID and PORT_CLIENT_SECRET after encoding them using base64. You can use portCredentials.yml as an example.
tip

If you save the CLIENT_ID and SECRET using the exact format shown in portCredentials.yml, you do not need to provide the parameters PORT_CREDENTIALS_SECRET, PORT_CLIENT_ID_KEY and PORT_CLIENT_SECRET_KEY when calling templates from the workflow template.

Verify​

To verify the installation of the workflow template, follow these steps:

  1. Go to the Codefresh interface;
  2. Under the CI OPS category, click on Workflow Templates;
  3. In the search bar, type port the workflow template should appear.

Usage​

Port's Codefresh workflow template supports the following methods:

  • Create/Update catalog entities - invoked with the upsert-entity template, receives the identifier and other properties of a new entity or an entity that needs to be updated;
  • Get catalog entities - invoked with the get-entity template, receives the identifier of an existing entity and retrieves it for use in your CI.
- name: entity-upsert
templateRef:
name: port
template: entity-upsert
arguments:
parameters:
# Note: if you save the CLIENT_ID and CLIENT_SECRET in the same format shown
# in the portCredentials.yml file, there is no need to provide
# PORT_CREDENTIALS_SECRET, PORT_CLIENT_ID_KEY, PORT_CLIENT_SECRET_KEY
- name: PORT_CREDENTIALS_SECRET
value: "port-credentials"
- name: PORT_CLIENT_ID_KEY
value: "PORT_CLIENT_ID"
- name: PORT_CLIENT_SECRET_KEY
value: "PORT_CLIENT_SECRET"
- name: BLUEPRINT_IDENTIFIER
value: "myBlueprint"
- name: ENTITY_IDENTIFIER
value: "myEntity"
- name: ENTITY_TITLE
value: "myTitle"
- name: ENTITY_PROPERTIES
value: |
{
"myStringProp": "My value",
"myNumberProp": 1,
"myBooleanProp": true,
"myArrayProp": ["myVal1", "myVal2"],
"myObjectProp": {"myKey": "myVal", "myExtraKey": "myExtraVal"}
}

Inputs

InputDescriptionNotes
PORT_CREDENTIALS_SECRETName of the secret to get the CLIENT_ID and CLIENT_SECRET fromDefault value: port-credentials
PORT_CLIENT_ID_KEYKey in the secret where the base64 encoded PORT_CLIENT_ID is storedDefault value: PORT_CLIENT_ID
PORT_CLIENT_SECRET_KEYkey in the secret where the base64 encoded PORT_CLIENT_SECRET is storedDefault value: PORT_CLIENT_SECRET
BLUEPRINT_IDENTIFIERIdentifier of the blueprint to create an entity ofRequired
ENTITY_IDENTIFIERIdentifier of the new (or existing) entityLeave empty to get an auto-generated identifier
ENTITY_TITLETitle of the new (or existing) entity
ENTITY_TEAMTeams array of the new (or existing) entity
ENTITY_ICONIcon of the new (or existing) entity
ENTITY_PROPERTIESProperties of the new (or existing) entity
ENTITY_RELATIONSRelations of the new (or existing) entity.

Outputs

OutputDescriptionNotes
ENTITY_IDENTIFIERidentifier of the new (or existing) entity

Examples​

Refer to the examples page for practical examples of Port's Codefresh workflow template.