diff --git a/versioned_docs/version-4.0.0/ci-cd/github.md b/versioned_docs/version-4.0.0/ci-cd/github.md index 4dbcd479b..8f62cba16 100644 --- a/versioned_docs/version-4.0.0/ci-cd/github.md +++ b/versioned_docs/version-4.0.0/ci-cd/github.md @@ -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 @@ -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=""` 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 "." \ + --cluster "" \ + --namespace "" \ + --delay +``` + +Replace ``, ``, ``, and `` with your own values. Set `` (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 . diff --git a/versioned_docs/version-4.0.0/ci-cd/gitlab.md b/versioned_docs/version-4.0.0/ci-cd/gitlab.md index a29506e4e..082315d24 100644 --- a/versioned_docs/version-4.0.0/ci-cd/gitlab.md +++ b/versioned_docs/version-4.0.0/ci-cd/gitlab.md @@ -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=""` 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 "." \ + --cluster "" \ + --namespace "" \ + --delay +``` + +Replace ``, ``, ``, and `` with your own values. Set `` 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. diff --git a/versioned_docs/version-4.0.0/ci-cd/jenkins.md b/versioned_docs/version-4.0.0/ci-cd/jenkins.md index cabb6bf68..de2572b73 100644 --- a/versioned_docs/version-4.0.0/ci-cd/jenkins.md +++ b/versioned_docs/version-4.0.0/ci-cd/jenkins.md @@ -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=""` 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 "." \ + --cluster "" \ + --namespace "" \ + --delay + ''' + } + } + } + } +} +``` + +Replace ``, ``, ``, and `` with your own values. Set `` 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.