- Authenticate to Endor Labs
- Install NodeJS plugin in Jenkins.
- Install your build toolchain
- Build your code
- Scan with Endor Labs
Authenticate to Endor Labs
To configure keyless authentication see the keyless authentication documentation. If you choose not to use keyless authentication you can configure an API key and secret in Jenkins for authentication using the following steps. See managing API keys for more information on generating an API key for Endor Labs.- In your Jenkins environment, navigate to Manage Jenkins.
- Enter a credential name for reference such as
endorlabsor reuse an existing context. - Click into your new or existing context. Add any project restrictions and select Add Environment Variable.
- In Environment Variable Name, enter ENDOR_API_CREDENTIALS_KEY and in Value, enter the Endor Labs API Key.
- Select Add Environment Variable.
Install Node.js plugin in Jenkins
See Jenkins documentation to install Node.js plugin in Jenkins. You must have the Node.js plugin to use npm and download endorctl.Configure your Jenkins pipeline
Important
Jenkins often checks out commits in a detached HEAD state, which can lead to fragmented branch tracking in Endor Labs. See Set up branch tracking in Jenkins to configure proper branch context.
Jenkins often checks out commits in a detached HEAD state, which can lead to fragmented branch tracking in Endor Labs. See Set up branch tracking in Jenkins to configure proper branch context.
- Create a configuration pipeline file in your repository if you do not already have one using the pipeline project.
- In your configuration pipeline file customize the job configuration based on your project’s requirements using one of the examples, simple Jenkins configuration or Jenkins pipeline using curl.
- Ensure that the context you created is part of the workflow if you are not using keyless authentication.
- Adjust the image field to conform to the required build tools for constructing your software packages, and synchronize your build steps with those of your project.
- Update your Endor Labs tenant namespace to the appropriate namespace for your project.
- Update your default branch from main if you do not use main as the default branch name.
- Modify any dependency or artifact caches to align with the languages and caches used by your project.
Examples
Use the following examples to get started. Make sure to customize this job with your specific build environment and build steps.Simple Jenkins configuration using npm
Jenkins pipe line for curl to download endorctl binary
The following example includes curl to download the endorctl binary.SAST scans in Jenkins
You can run SAST scans in your Jenkins pipeline to identify security vulnerabilities and code quality issues in your source code. SAST scanning analyzes your source code for potential security weaknesses based on enabled rules and generates findings based on your configured finding policies.SAST scan
To run a SAST scan, add the--sast flag to your endorctl scan command.
AI-analyzed SAST scan
To enable AI SAST analysis, add the--sast and --ai-sast-analysis=agent-fallback flags to your endorctl scan command. The AI agent automatically classifies findings as true positives or false positives, reducing the need for manual triage.
--ai-sast-rescan flag.
Set up branch tracking in Jenkins
In Git, a detached HEAD state occurs when the repository checks out a specific commit instead of a branch reference. In this state, Git points the HEAD directly to a commit hash, without associating it with a named branch. As a result, actions performed, such as creating new commits or running automated scans, do not carry branch identity unless explicitly specified. Proper branch context enables Endor Labs to:- Associate scans with the correct branch
- Identify scans on the monitored default branch
- Track findings and display metrics accurately across branches
Jenkins often checks out commits by their SHA instead of the branch name, which creates a detached HEAD state.
Use --detached-ref-name only to specify the branch name for a commit in detached HEAD state. This associates the commit with the correct branch without setting it as the default branch.
--detached-ref-name and --as-default-branch together when you want to associate the commit with a branch and set it as the default branch scan.