Generate an API Token


Navigate to the tokens page

Hover over your avatar, wait for the dropdown menu and select API Tokens.

Drop Down Menu

Generate a new token

Hit the Generate a new API token button.

Generate Token

Provide your login credentials, if prompted. You will be redirected to see your new API Token.

Generate Token

Use the Copy token button to copy the token and store it in a secure place.

This is the only time you’ll see the token here and there’ll be no way to retrieve it later. If you lose it, you will have to revoke all your API tokens and regenerate new ones.

Set up your CI/CD platform


Store the Diversion client ID

Store it as an environment variable named USER_POOL_CLIENT_ID with the value 769th1pmk6r3d9t6ari1piu3ds.
It will be read and used by the dv client in the workflow.

Here are some relevant docs for storing environment variables in popular CI/CD platforms:


Store the API Token securely

Don’t store the API Token as a plain environment variable! If your CI/CD platform provides a secure secret storage, use it.
Here are some relevant docs for storing secrets in popular CI/CD platforms:

If your platform doesn’t support secure secrets handling, you can use external secret handling tools:

Create a build step in your CI/CD workflow

Install the Diversion client, authenticate it and clone your repo

In your CI/CD step editor or yml file, create a new Shell build step with the following content:

# Download Diversion client
curl -sL | bash ; export PATH="$HOME/.diversion/bin:$PATH"
# Authenticate Diversion
dv authenticate $API_TOKEN
# Clone your repository and wait for sync to complete
dv clone -new-workspace my-repository
cd my-repository
dv status
Replace $API_TOKEN with the appropriate way to reference your secret from the secure storage. Consult your platform’s docs and the secure storage docs.
Replace my-repository with the name of your repository.
dv status will block until all the files are downloaded. This is important before starting to work. It will also output the workspace ID if you want to reuse it for the next runs or view it in the web app.
-new-workspace will create a new workspace for each run of the CI/CD workflow. Passing a workspace argument here is important, or else the clone command will prompt for user input and block. See dv help clone for details.

Add the rest of your CI/CD workflow

That’s it. You’re all set to use your Diversion repo in your CI/CD workflow. You can also use any CLI commands you would use with dv when running locally.