Skip to main content

Jenkins Pipeline

Basic example

Here's how you can integrate Escape into your Jenkins Pipeline in your Jenkinsfile:

pipeline {
agent { label 'node' } // Use a node with Node.js installed

environment {
ESCAPE_APPLICATION_ID = credentials('ESCAPE_APPLICATION_ID')
ESCAPE_API_KEY = credentials('ESCAPE_API_KEY')
}

stages {
stage('Checkout') {
steps {
checkout scm // Checkout the codebase from the SCM provider
}
}

stage('Post-Deploy') {
when {
branch 'staging' // Only run on the 'staging' branch
}

steps {
script {
// Install the Escape CLI tool
sh 'npm install -g @escape.tech/action'

// Show the installed Escape CLI version
sh 'npm show @escape.tech/action version'

// Run Escape action
sh 'escape-action'
}
}

post {
always {
// Configuration to allow failure
}
}
}
}
}

This example Jenkinsfile does the following:

  • Sets up an environment with Node.js.
  • Loads the ESCAPE_APPLICATION_ID and ESCAPE_API_KEY from Jenkins' stored credentials.
  • Checks out the codebase from your SCM (Source Control Management).
  • Runs the Escape action in the Post-Deploy stage, specifically when the branch is staging.

Available variables

ESCAPE_APPLICATION_ID string required

The id of the application on Escape that will be scanned continuously.
You can find it in your Escape application settings.

ESCAPE_API_KEY string required

Your API key on the Escape platform.
You can find it in your Escape settings.

TIMEOUT number

The timeout of the job. If set to 0, the scan will be started, but the job will not wait for it to be finished before terminating.

The triggered scan will run asynchronously on Escape, and your team will be notified once it is done using your desired notifications settings.

CONFIGURATION_OVERRIDE string

See the configuration override section.

CONFIGURATION_OVERRIDE_PATH string

See the configuration override section.

COMMIT_HASH string

See the commit identification section.

INTROSPECTION_FILE number

See the introspection update section.