To define a declarative pipeline, you use a Jenkinsfile file that contains the Pipeline script. The basic steps are as follows:
-
Create Jenkinsfile.
Include the following code snippet as the content of the Jenkinsfile depending on whether you want to use Sigma as a quality gate or whether you want to report Sigma issues within Jenkins. Make sure to replace the following tokens in the template with actual values.
-
GIT_REPO_URL: This is the URL to the Git repository where the source code is stored. -
SIGMA_TOOL_NAME: This is the name of the Sigma installation you specified when you configured the Sigma installation.
Template for using Sigma as a quality gate
pipeline { agent any stages { stage('Sigma') { steps { sigma ignorePolicies: false, sigmaToolName: '<SIGMA_TOOL_NAME>' } } stage('Sigma Results') { steps { archiveArtifacts 'sigma-results.json' } } } }Template for using Sigma to report issues within Jenkins
pipeline { agent any stages { stage('Sigma') { steps { sigma ignorePolicies: true, sigmaToolName: '<SIGMA_TOOL_NAME>' } } stage('Sigma Results') { steps { archiveArtifacts 'sigma-results.json' recordIssues(tools: [[$class: 'SigmaTool']]) } } } } -
- Check Jenkinsfile into your source code reopsitory that contains the code for Sigma to scan.
- Define a pipeline following the steps in Defining a Jenkins Pipeline. Make sure to select Pipeline script from SCM from the Pipeline Definition field in step 3.
-
Configure the SCM to pull the source code to scan from a repository.
Select the SCM from which to pull the source code to scan from a repository. By default, the build will search for
Jenkinsfilein the source code pulled from the repository.Use the following Pipeline dialog to specify this information.
For example, you might fill out these fields as follows:
- Definition: Pipeline script from SCM
- SCM: Git
- Script Path: Jenkinsfile
- Lightweight checkout: checked
- Pipeline Syntax: a link to a utility that helps you define the correct Pipline syntax for your build