Skip to main content
Mock API Builder
Learning Center/Integration/CI/CD Integration
Integration

CI/CD Integration

Use mock APIs in your continuous integration and deployment pipelines

CI/CD with Mock APIs

Integrate Mock API Builder into your CI/CD pipeline to run automated tests, validate integrations, and ensure your application works correctly before deploying to production.

Automated Testing

Run integration tests against mock APIs in every build

Fast Feedback

Get quick test results without waiting for real APIs

Consistent Data

Use predictable mock data across all test runs

Developer / CI API

Automate project management from CI with the Developer API under /api/v1/.... Authenticate with your user API token (generate or refresh it from your profile). The token must belong to the project owner.

Authentication

Pass your API token with either header:

plaintext

Authorization: Token <apiToken> is also accepted. Store the token as a CI secret (for example MOCK_API_TOKEN)—never commit it.

Available Endpoints

All routes are scoped to a project you own by :slug:

MethodPathDescription
GET/api/v1/projects/:slugProject metadata (name, protocol, mock base URL, endpoint count, and more)
GET/api/v1/projects/:slug/endpointsList endpoints
POST/api/v1/projects/:slug/endpointsCreate an endpoint (path, method, optional mockData, config, enabled)
PATCH/api/v1/projects/:slug/endpoints/:idUpdate an endpoint (path, mockData, config, enabled, contract)
PUT/api/v1/projects/:slug/settingsUpdate settings (proxyMode, isPublic, apiTokenRequired, monitor target, forward headers)
GET/api/v1/projects/:slug/logsRecent request logs (?limit=, default 50, max 200)
POST/api/v1/projects/:slug/state/resetClear the stateful mock store for the project
Example: Reset State Before Tests
bash

Use the same token header pattern for listing endpoints, updating mock data, toggling MOCK/PROXY/HYBRID, or fetching logs after a pipeline run.

GitHub Actions

Basic Workflow with Mock API

Create a .github/workflows/test.yml file in your repository:

plaintext
Advanced Workflow with Multiple Environments
plaintext

GitLab CI/CD

GitLab Pipeline Configuration

Create a .gitlab-ci.yml file:

plaintext

Jenkins

Jenkinsfile Configuration

Create a Jenkinsfile in your repository:

plaintext

CircleCI

CircleCI Configuration

Create a .circleci/config.yml file:

plaintext

Managing Environment Variables

Setting Up Mock API URLs

GitHub Actions Secrets

  1. Go to repository Settings → Secrets and variables → Actions
  2. Click "New repository secret"
  3. Add MOCK_API_URL with your project URL
  4. Add MOCK_API_TOKEN if using authentication

GitLab CI/CD Variables

  1. Go to Settings → CI/CD → Variables
  2. Click "Add variable"
  3. Set key as API_URL, value as your mock API URL
  4. Check "Protect variable" and "Mask variable" for security

Jenkins Credentials

  1. Go to Manage Jenkins → Credentials
  2. Add new credentials (Secret text)
  3. Use ID like mock-api-url
  4. Reference in Jenkinsfile with credentials('mock-api-url')
Environment-Specific Configuration

Use different mock APIs for different environments:

javascript

Testing Strategies

Unit Tests with Mock APIs
javascript
Integration Tests
javascript
E2E Tests with Playwright/Cypress
javascript

Best Practices

  • ✓Use environment variables for API URLs—never hardcode them in tests
  • ✓Create dedicated mock projects for CI/CD to avoid conflicts with development
  • ✓Run tests in parallel when possible to speed up builds
  • ✓Cache dependencies (node_modules) to reduce build times
  • ✓Fail fast run quick tests (unit) before slow tests (E2E)
  • ✓Store test results as artifacts for debugging failed builds
  • ✓Use matrix builds to test against multiple Node.js versions
  • ✓Monitor CI/CD performance and optimize slow steps
Previous: Search & Filter
Mock API Builder

Built for developers, by developers

DocumentationContactPrivacy PolicyTerms of Service

© 2026 Mock API Builder. All rights reserved.

Double-click for what's new
Learning Center
Learning Center