Skip to content

Jenkins

Trigger Smoketest deployment webhooks from Jenkins Pipeline after a deploy stage.

View as Markdown

Use Jenkins when your deploy pipeline owns the final deployment step. Add a Smoketest stage after deployment and pass the deployed URL plus Jenkins build metadata.

Before you start

  1. Create a deployment webhook in Smoketest.
  2. Store the trigger URL as a Jenkins credential named smoketest-deployment-webhook-url.
  3. Make sure the agent running the stage has curl.

Declarative Pipeline

Jenkinsfile
pipeline {
  agent any

  environment {
    DEPLOYMENT_URL = 'https://staging.example.com'
  }

  stages {
    stage('Deploy') {
      steps {
        sh './scripts/deploy.sh'
      }
    }

    stage('Smoketest') {
      steps {
        withCredentials([string(credentialsId: 'smoketest-deployment-webhook-url', variable: 'SMOKETEST_DEPLOYMENT_WEBHOOK_URL')]) {
          sh '''
            curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
              -H "Idempotency-Key: ${BUILD_TAG}" \
              --data-urlencode "targetUrl=${DEPLOYMENT_URL}" \
              --data-urlencode "commitSha=${GIT_COMMIT}" \
              --data-urlencode "branch=${BRANCH_NAME}" \
              --data-urlencode "externalId=${BUILD_TAG}"
          '''
        }
      }
    }
  }
}

Scripted Pipeline

Jenkinsfile
node {
  stage('Deploy') {
    sh './scripts/deploy.sh'
  }

  stage('Smoketest') {
    withCredentials([string(credentialsId: 'smoketest-deployment-webhook-url', variable: 'SMOKETEST_DEPLOYMENT_WEBHOOK_URL')]) {
      sh '''
        curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
          -H "Idempotency-Key: ${BUILD_TAG}" \
          --data-urlencode "targetUrl=${DEPLOYMENT_URL}" \
          --data-urlencode "commitSha=${GIT_COMMIT}" \
          --data-urlencode "branch=${BRANCH_NAME}" \
          --data-urlencode "externalId=${BUILD_TAG}"
      '''
    }
  }
}

If your Jenkins job is not branch-aware, BRANCH_NAME may be empty. Omit the branch parameter or set it explicitly.

On this page