Role: Pipeline owner  ·  Time: about 10 minutes

There is no Jenkins plugin yet. Use a shell step (Declarative Pipeline or Freestyle). The CLI posts snapshot or restore and waits (--wait is the default). Exit 0 means SUCCESS; exit 1 means FAILED or SKIPPED — fail the build on that.

Recipes: Restore before tests and Snapshot before deploy. Install steps: Install and configure the quemsi CLI.

Before you start

Steps

1

Store credentials in Jenkins

Manage Jenkins → Credentials → (domain) → Add credentials.

  • Secret text for the token: ID quemsi-token, secret = qsk_….
  • Optional Secret text for the URL: ID quemsi-url, secret = https://quemsi.com (or your host). If omitted, the CLI defaults to https://quemsi.com.

Do not put the token in the Jenkinsfile or in Git.

2

Install the CLI on the Jenkins agent

Prefer baking quemsi into the agent image or tool installation so every job does not download. One-shot install in a pipeline stage also works:

curl -fsSL -o quemsi https://quemsi.com/cli-releases/latest/quemsi
chmod +x quemsi
sudo mv quemsi /usr/local/bin/quemsi
quemsi --help

On Windows agents, download quemsi.exe onto PATH. Full options: Install and configure the quemsi CLI.

3

Restore before tests (Declarative Pipeline)

Restore overwrites the target database. Use a CI/test datasource, not production. The CLI prints you can watch progress at …/app/flows/execution/{id} on stderr while it waits.

pipeline {
  agent any
  environment {
    QUEMSI_TOKEN = credentials('quemsi-token')
    // Optional: QUEMSI_URL = credentials('quemsi-url')
  }
  stages {
    stage('Restore known state') {
      steps {
        sh '''
          quemsi restore \
            --agent ci-staging \
            --target-datasource app-db \
            --data shopping-cart \
            --tag use-case=e2e-baseline
        '''
      }
    }
    stage('Test') {
      steps {
        sh './gradlew test'   // or mvn test, npm test, …
      }
    }
  }
}

Replace names and tags with yours. Full restore contract: Restore before tests.

4

Snapshot before deploy (Declarative Pipeline)

Do not migrate or deploy until the snapshot stage exits 0.

pipeline {
  agent any
  environment {
    QUEMSI_TOKEN = credentials('quemsi-token')
  }
  stages {
    stage('Snapshot before deploy') {
      steps {
        sh '''
          quemsi snapshot \
            --data shopping-cart \
            --agent ci-staging \
            --tag release=${BUILD_NUMBER} \
            --tag purpose=pre-deploy \
            --descript "Jenkins build ${BUILD_TAG}"
        '''
      }
    }
    stage('Deploy') {
      steps {
        sh './deploy.sh'
      }
    }
  }
}

Use a distinct tag combination so Restore can find this card later. Details: Snapshot before deploy.

5

Freestyle job (optional)

Add a Secret text binding for QUEMSI_TOKEN, then an Execute shell build step with the same quemsi restore or quemsi snapshot command. Mark the build failed if the step returns non-zero (Jenkins does this by default for shell steps).

Tips

Not this page

Credentials, then a shell stage

Store QUEMSI_TOKEN in Jenkins, put quemsi on the agent PATH, and fail the build if snapshot or restore exits non-zero.

Open API tokens

Next