Jenkins
Trigger Smoketest deployment webhooks from Jenkins Pipeline after a deploy stage.
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
- Create a deployment webhook in Smoketest.
- Store the trigger URL as a Jenkins credential named
smoketest-deployment-webhook-url. - Make sure the agent running the stage has
curl.
Declarative Pipeline
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
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.