Skip to main content

Check out Port for yourselfย 

Circle CI Actions

Port's Circle CI integration allows you to trigger new pipelines in Circle CI directly from Port.

Overviewโ€‹

You can implement this action in two ways:

  1. Synced webhook and secrets: A simpler approach that uses Port's secret management to store your Circle CI credentials.
  2. Execution agent: A slightly more complex approach that runs within your infrastructure, keeping credentials in your environment.

Prerequisitesโ€‹

  • A Circle CI personal API token.
  • If you choose to implement using the Execution Agent, you will need to:
    • Install Helm on your infrastructure
    • Contact Port support to set up a Kafka topic for your organization.

Set up data modelโ€‹

Before implementing either approach, you will need to create a blueprint for Circle CI projects:

  1. Go to your Builder page.

  2. Click on + Blueprint.

  3. Click on the {...} button in the top right corner, and choose "Edit JSON".

  4. Add this JSON schema:

    Circle CI project blueprint
    {
    "identifier": "circle_ci_project",
    "title": "CircleCI Project",
    "icon": "CircleCI",
    "schema": {
    "properties": {
    "project_slug": {
    "title": "Slug",
    "type": "string"
    }
    },
    "required": ["project_slug"]
    },
    "mirrorProperties": {},
    "calculationProperties": {},
    "relations": {}
    }
  5. Click Save to create the blueprint.

Implementationโ€‹

You can trigger Circle CI pipelines by leveraging Port's synced webhooks to directly interact with the Circle CI API and secrets to store your Circle CI credentials. This method simplifies the setup by handling everything within Port.

Add Port secrets

To add Circle CI credentials to your portal:

  1. Click on the ... button in the top right corner of your Port application.

  2. Click on Credentials.

  3. Click on the Secrets tab.

  4. Click on + Secret and add:

    • CIRCLE_CI_TOKEN: Your Circle CI personal API token
    • CIRCLE_CI_URL: The URL of your Circle CI instance (e.g., https://circleci.com)

Create Circle CI self-service action

To create a self-service action that triggers a Circle CI pipeline, follow these steps:

  1. Head to the self-service page.

  2. Click on the + New Action button.

  3. Click on the {...} Edit JSON button.

  4. Copy and paste the following JSON configuration into the editor.

    Trigger Circle CI pipeline action
    {
    "identifier": "circle_ci_project_trigger_pipeline",
    "title": "Trigger CircleCI pipeline",
    "icon": "CircleCI",
    "trigger": {
    "type": "self-service",
    "operation": "DAY-2",
    "userInputs": {
    "properties": {
    "branch": {
    "title": "Branch",
    "type": "string",
    "default": "main"
    },
    "parameters": {
    "title": "Parameters",
    "type": "object",
    "default": {}
    }
    },
    "required": ["branch"],
    "order": ["branch", "parameters"]
    },
    "blueprintIdentifier": "circle_ci_project"
    },
    "invocationMethod": {
    "type": "WEBHOOK",
    "url": "{{.secrets.CIRCLE_CI_URL}}/api/v2/project/{{.entity.properties.project_slug}}/pipeline",
    "agent": false,
    "synchronized": true,
    "method": "POST",
    "headers": {
    "Circle-Token": "{{.secrets.CIRCLE_CI_TOKEN}}",
    "Content-Type": "application/json"
    },
    "body": {
    "branch": "{{.inputs.branch}}",
    "parameters": "{{.inputs.parameters}}"
    }
    },
    "requiredApproval": false
    }
  5. Click Save.

Now you should see the Trigger Circle CI Pipeline action in the self-service page. ๐ŸŽ‰

Let's test it!โ€‹

  1. Head to the self-service page of your portal

  2. Click on Trigger Circle CI Pipeline

  3. Fill in the pipeline details:

    • Branch to run the pipeline on (defaults to main)
    • Any additional parameters configured in the action
  4. Click on Execute

  5. Wait for the pipeline to be triggered in Circle CI

  6. Check your Circle CI project page to see the new pipeline running