Skip to content
Merged
61 changes: 60 additions & 1 deletion versioned_docs/version-4.0.0/ci-cd/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Keploy can be integrated with GitHub by two methods:-
1. [Using Shell Scripts](#shell-scripts)
2. [Using GitHub Actions](#github-actions)

You can also [run cloud replay from your CI pipeline](#running-cloud-replay-in-ci).

## Shell Scripts

GitHub scripts are the easiest way to integrate Keploy with GitHub. We will be using [express-mongoose](https://github.com/keploy/samples-typescript/tree/main/express-mongoose) sample-application for the example. You can either add the following script to yout `github workflow` or create a new worflow `.github/workflows/keploy-test.yml`:-
GitHub scripts are the easiest way to integrate Keploy with GitHub. We will be using [express-mongoose](https://github.com/keploy/samples-typescript/tree/main/express-mongoose) sample-application for the example. You can either add the following script to your `github workflow` or create a new workflow `.github/workflows/keploy-test.yml`:-

```yaml
- name: Checkout Commit
Expand Down Expand Up @@ -215,4 +217,61 @@ sudo -E keploy test -c node src/app.js --delay 10 --path ./

_And... voila! You have successfully integrated keploy in GitHub CI pipeline 🌟_

---

## Running cloud replay in CI

Keploy cloud replay re-runs test sets that were recorded from a Kubernetes deployment. It works with both **Keploy Cloud** and a **self-hosted Keploy** setup, and on any CI control plane — GitHub Actions, GitLab CI, Jenkins, and others.

### How authentication works

The CLI reads the `KEPLOY_API_KEY` environment variable automatically — no browser login needed.

- **Locally:** `export KEPLOY_API_KEY="<your-api-key>"` before running the command.
- **In CI:** store the key as a secret in your CI system so it gets injected as an environment variable at runtime. Never hard-code it in your pipeline file.

> Cloud replay requires the Enterprise binary (`keploy.io/ent/dl/latest/enterprise_linux_amd64`), not the open-source one.

### Steps

1. **Store the API key** — add `KEPLOY_API_KEY` as a secret in your CI system.
- GitHub Actions: go to **Settings → Secrets and variables → Actions → New repository secret**, name it `KEPLOY_API_KEY`.
- GitLab CI: go to **Settings → CI/CD → Variables**, add it as a masked variable.
- Jenkins: add a **Secret text** credential via **Manage Jenkins → Credentials**.
2. **Install** the Enterprise Keploy binary on the runner.
3. **Run** `keploy cloud replay` with your application and cluster details.

### Example: GitHub Actions

```yaml
name: Keploy Cloud Replay

on:
push:
branches: [main]

jobs:
keploy-cloud-replay:
runs-on: ubuntu-latest
env:
KEPLOY_API_KEY: ${{ secrets.KEPLOY_API_KEY }}
steps:
- name: Install Keploy Enterprise
run: |
curl --silent --location "https://keploy.io/ent/dl/latest/enterprise_linux_amd64" -o /tmp/keploy
sudo chmod +x /tmp/keploy && sudo mv /tmp/keploy /usr/local/bin/keploy

- name: Cloud replay
run: |
keploy cloud replay \
--app "<NAMESPACE>.<DEPLOYMENT>" \
--cluster "<CLUSTER>" \
--namespace "<NAMESPACE>" \
--delay <DELAY>
```

Replace `<NAMESPACE>`, `<DEPLOYMENT>`, `<CLUSTER>`, and `<DELAY>` with your own values. Set `<DELAY>` (in seconds) to comfortably cover your application's startup time.

> `KEPLOY_API_KEY: ${{ secrets.KEPLOY_API_KEY }}` pulls the value from GitHub's secret store and makes it available as an environment variable in all subsequent steps.

Hope this helps you out, if you still have any questions, reach out to us .
46 changes: 46 additions & 0 deletions versioned_docs/version-4.0.0/ci-cd/gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,49 @@ Integrating Keploy with GitLab CI automates the testing process, ensuring that t
If you’re thinking, “This pipeline looks cool, but I need the _whole thing_ to integrate with your application!” — well, you're in luck! Check it out [here](https://github.com/keploy/samples-python) and get ready to copy-paste your way to success! ✨🚀

Hope this helps you out, if you still have any questions, reach out to us .

---

## Running cloud replay in CI

Keploy cloud replay re-runs test sets that were recorded from a Kubernetes deployment. It works with both **Keploy Cloud** and a **self-hosted Keploy** setup — the command is the same either way.

### How authentication works

The CLI reads the `KEPLOY_API_KEY` environment variable automatically. You do not need to pass it as a flag or log in through a browser.

- Locally: `export KEPLOY_API_KEY="<your-api-key>"` before running the command.
- In CI: add the key as a masked CI/CD variable so the system injects it as an environment variable at runtime. Never hard-code it in your pipeline file.

In GitLab CI, go to **Settings → CI/CD → Variables**, add `KEPLOY_API_KEY` as a masked variable, and it is automatically available in all pipeline jobs as `$KEPLOY_API_KEY`.

### Steps

1. Add `KEPLOY_API_KEY` as a masked CI/CD variable (**Settings → CI/CD → Variables**).
2. Install the Enterprise Keploy binary on the runner.
3. Run `keploy cloud replay` with your application and cluster details.

> Cloud replay requires the Enterprise binary (`keploy.io/ent/dl/latest/enterprise_linux_amd64`), not the open-source one.

### Example: GitLab CI

```yaml
keploy-cloud-replay:
stage: test
image: ubuntu:22.04
# KEPLOY_API_KEY is injected automatically from the masked CI/CD variable
script:
- apt-get update -qq && apt-get install -y -qq curl sudo
- curl --silent --location "https://keploy.io/ent/dl/latest/enterprise_linux_amd64" -o /tmp/keploy
- chmod +x /tmp/keploy && mv /tmp/keploy /usr/local/bin/keploy
- |
keploy cloud replay \
--app "<NAMESPACE>.<DEPLOYMENT>" \
--cluster "<CLUSTER>" \
--namespace "<NAMESPACE>" \
--delay <DELAY>
```

Replace `<NAMESPACE>`, `<DEPLOYMENT>`, `<CLUSTER>`, and `<DELAY>` with your own values. Set `<DELAY>` to cover your application's startup time (in seconds).

> Because `KEPLOY_API_KEY` is defined as a masked variable in GitLab, it is already present in the job's environment — no `export` step is needed.
58 changes: 58 additions & 0 deletions versioned_docs/version-4.0.0/ci-cd/jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,61 @@ Testrun passed for testcase with id: "test-2"
_And... voila! You have successfully integrated keploy in Jenkins CI/CD pipeline 🌟_

Hope this helps you out, if you still have any questions, reach out to us .

---

## Running cloud replay in CI

Keploy cloud replay re-runs test sets that were recorded from a Kubernetes deployment. It works with both **Keploy Cloud** and a **self-hosted Keploy** setup — the command is the same either way.

### How authentication works

The CLI reads the `KEPLOY_API_KEY` environment variable automatically. You do not need to pass it as a flag or log in through a browser.

- Locally: `export KEPLOY_API_KEY="<your-api-key>"` before running the command.
- In CI: add the key to Jenkins' credentials store so the system injects it as an environment variable at runtime. Never hard-code it in your Jenkins pipeline file.

In Jenkins, go to **Manage Jenkins → Credentials**, add a **Secret text** credential with ID `keploy-api-key`, and use `withCredentials` in your pipeline to bind it to `KEPLOY_API_KEY`.

### Steps

1. Add `KEPLOY_API_KEY` as a **Secret text** credential in Jenkins (**Manage Jenkins → Credentials**).
2. Install the Enterprise Keploy binary on the agent.
3. Run `keploy cloud replay` with your application and cluster details.

> Cloud replay requires the Enterprise binary (`keploy.io/ent/dl/latest/enterprise_linux_amd64`), not the open-source one.

### Example: Jenkins Declarative Pipeline

```groovy
pipeline {
agent any
stages {
stage('Install Keploy Enterprise') {
steps {
sh '''
curl --silent --location "https://keploy.io/ent/dl/latest/enterprise_linux_amd64" -o /tmp/keploy
sudo chmod +x /tmp/keploy && sudo mv /tmp/keploy /usr/local/bin/keploy
'''
}
}
stage('Cloud replay') {
steps {
withCredentials([string(credentialsId: 'keploy-api-key', variable: 'KEPLOY_API_KEY')]) {
sh '''
keploy cloud replay \
--app "<NAMESPACE>.<DEPLOYMENT>" \
--cluster "<CLUSTER>" \
--namespace "<NAMESPACE>" \
--delay <DELAY>
'''
}
}
}
}
}
```

Replace `<NAMESPACE>`, `<DEPLOYMENT>`, `<CLUSTER>`, and `<DELAY>` with your own values. Set `<DELAY>` to cover your application's startup time (in seconds).

> `withCredentials` binds the Jenkins secret to `KEPLOY_API_KEY` only for the duration of that stage — the CLI picks it up automatically.
Loading