Created
April 7, 2023 15:45
-
-
Save mattatsnyk/3f70fdee3c6b5e2dccb99ceb4fa00ff4 to your computer and use it in GitHub Desktop.
example-jenkinsfile-for-.NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
// Requires a configured NodeJS installation via https://plugins.jenkins.io/nodejs/ | |
tools { nodejs "NodeJS 18.4.0" } | |
stages { | |
stage('git clone') { | |
steps { | |
git url: 'https://github.com/mattatsnyk/TodoList-.net' | |
} | |
} | |
// Install the Snyk CLI and snyk-to-html with npm. For more information, check: | |
// https://docs.snyk.io/snyk-cli/install-the-snyk-cli | |
stage('Get npm and snyk-to-html'){ | |
steps { | |
script { | |
sh """ | |
npm install snyk -g | |
npm install snyk-to-html -g | |
""" | |
} | |
} | |
} | |
// Authorize the Snyk CLI | |
stage('Authorize Snyk CLI') { | |
steps { | |
withCredentials([string(credentialsId: 'SNYK_TOKEN', variable: 'SNYK_TOKEN')]) { | |
sh 'snyk auth ${SNYK_TOKEN}' | |
} | |
} | |
} | |
stage('Build App') { | |
steps { | |
// Replace this with your build instructions, as necessary. | |
sh 'dotnet restore' | |
} | |
} | |
stage('Snyk open source test') { | |
parallel { | |
stage('Snyk Open Source') { | |
steps { | |
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { | |
sh 'snyk test --sarif-file-output=results-open-source.sarif || true' | |
sh 'cat results-open-source.sarif | snyk-to-html > results-open-source.html' | |
} | |
recordIssues tool: sarif(name: 'Snyk Open Source', id: 'snyk-open-source', pattern: 'results-open-source.sarif') | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment